开发者

Remove file from the repository but keep it locally

开发者 https://www.devze.com 2023-01-11 02:12 出处:网络
I have a fo开发者_如何学Pythonlder which I\'d like to remove in my remote repository. I\'d like to delete it, but keep the folder in my computergit rm --cached -r somedir

I have a fo开发者_如何学Pythonlder which I'd like to remove in my remote repository. I'd like to delete it, but keep the folder in my computer


git rm --cached -r somedir

Will stage the deletion of the directory, but doesn't touch anything on disk. This works also for a file, like:

git rm --cached somefile.ext

Afterwards you may want to add somedir/ or somefile.ext to your .gitignore file so that git doesn't try to add it back.


I would just:

  • Move the folder out of your working tree
  • git rm the folder, commit the change
  • Add to .gitignore (or .git/info/excludes), commit the change
  • Move the folder back
0

精彩评论

暂无评论...
验证码 换一张
取 消