0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

giboを使用して.gitignoreを作成したのに反映されなかった話

Posted at

結論

PowerShell
gibo dump <使用している言語やプラットフォーム> | Out-File .gitignore -Encoding UTF8

.gitignoreの文字コードをUTF-8にすることで解決。

やったこと

PyCharmでPythonを弄っているのでpythonとJetBrainsを指定している。

giboで.gitignoreを作成

Terminal
gibo dump python JetBrains >> .gitignore
git git status --ignored
--略
Ignored files:
  (use "git add -f <file>..." to include in what will be committed)
        .idea/workspace.xml

無視するファイルが足りてない。1

キャッシュの削除2

Terminal
git rm -r --cached .
fatal: pathspec '.' did not match any files

対象のファイルが存在しないと怒られる。git addしてないので当然対象となるようなファイルは無い。
キャッシュが存在すると.gitignoreでは無視しなくなるが今回は当てはまらなかった。
ワイルドカードの指定がうまくできていなかったのかとしばらくrm -r --cachedを試す。

.config\git\ignoreを設定

Terminal
gibo dump python JetBrains >> ignore
git git status --ignored
--略
Ignored files:
  (use "git add -f <file>..." to include in what will be committed)
        .idea/workspace.xml
        __pycache__/
        venv/

リポジトリ全体で共有されるgitignoreを設定したらとりあえず出来た。なんか気に食わないので削除して検索を続ける。

文字コードによって認識されないらしい

どうやらPowerShellでリダイレクトして作成したテキストファイルは文字コードがUnicode(UTF-16LE)になるらしく、gitが認識してくれなかった模様。3

Terminal
git git status --ignored
--略
Ignored files:
  (use "git add -f <file>..." to include in what will be committed)
        .idea/workspace.xml
        __pycache__/
        venv/

文字コードをUTF-8にしたところ認識された。

いっぺんに済ませたい

gibo dump python JetBrains >> .gitignoreって入力してからテキストエディタ開いてUTF-8に変更してって作業になる。つらい。 IDEなら文字コードを変換できることに今更気が付いた。もっとつらい。

Terminal
gibo dump python JetBrains | Out-File .gitignore -Encoding UTF8
git git status --ignored
--略
Ignored files:
  (use "git add -f <file>..." to include in what will be committed)
        .idea/workspace.xml
        __pycache__/
        venv/

Out-Fileコマンドを使用して文字コードをUTF-8に指定する。

giboの使い方

コードを落としてpath通せばいいというざっくりとした認識。

  1. 無視されているのはIDEが初期設定で指定しているもの。__pycache__やvenvディレクトリも無視されるはずだった。

  2. https://qiita.com/fuwamaki/items/3ed021163e50beab7154

  3. https://qiita.com/ogsoon/items/a2325f44f558c4c4aceb ここを見ればこの記事なんていらない。先にこっちを見つけていればこの記事を書くこともなかった。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?