Git: How to remove file from index without deletin

2019-01-12 15:22发布

When you use

git rm --cached myfile

it doesn't delete from the local filesystem, which is the goal. But if you've already versioned and committed the file, pushed it to a central repository, and pulled it into yet another repository before using the command, it will delete the file from that system.

Is there a way to just remove the file from versioning without deleting it from any filesystem?

Edit: Clarified, I hope.

7条回答
Summer. ? 凉城
2楼-- · 2019-01-12 16:11
  1. git rm --cached remove_file
  2. add file to gitignore
  3. git add .gitignore
  4. git commit -m "Excluding"
  5. Have fun ;)
查看更多
登录 后发表回答