LoginSignup
14
15

More than 5 years have passed since last update.

jupyterのcheckpoints関連ファイルをgit管理から外す

Posted at

.ipynb_checkpoints/以下のファイルまでgit管理の対象とすると、mergeやpullなどで、以下のようなエラーが発生する場合がある。

error: The following untracked working tree files would be overwritten by merge:

なので、gitignoreファイルを作成し、git管理から外す。

まず

touch .gitignore

で空のファイルを作成し、ファイルの中に

notebookが置いてあるフォルダパス/.ipynb_checkpoints/

と書いて保存する。
※/.ipynb_checkpoints/以下のファイルはすべて管理対象から外す、という記述

すでに一度git管理下に置いてしまっている場合(エラーが出るということはgit管理しているということ)は

git rm -r --cached .

でいったん、git管理からすべて外す。
※rmコマンド入ってますが、ファイル自体を消すわけじゃないです。

あとは普通にgit addすればよいが、それをやるまえに
ほんとに管理対象から外れているか確認するには、以下のコマンドを叩けば、管理外のファイルが表示される

git ls-files --other --ignored --exclude-standard
14
15
1

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
14
15