开发者

Git remove *.sln.docstates from repository

Somehow I accidentally committed a .sln.docstates file. Now I added it to the gitignore, how开发者_如何学Cever it won't be ignored. I think this is because I already committed it once. Don't know when!

Is there a possibility to make this gitignore rule working? How can I delete it from my repository?

*.sln.docstates


Remove it this way:

$ git rm --cached \*.sln.docstates

…then the .gitignore should be honoured.


It depends on whether you have pushed the repository changes or the changes are local.

If you already pushed the changes to the remote repository then you are not supposed to rewrite history.

If your changes are only local you use git log .sln.docstates to find out the history of the files and locate the commit where you added the file. The removal of the file from commits requires some git filter-branch magic, see a corresponding answer.

The situation is simpler if the file is only present in the most recent unpublished commit: you can use git rm --cached .sln.docstates and git commit --amend. (The --cached switch tells git to don't touch your files and remove it from the index only, and then you modify your last commit instead of creating a new using the --amend switch.)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜