我如何使用文件“.git/info/exclude” 为时已晚?
我通常这样做:
git init
git add .
git commit .
然后我意识到它将添加我的 nbproject 目录,我想要排除/忽略该目录。 有时,我什至会检查这个目录。 如果我在运行 git add .
之前将其添加到 .git/info/exclude 中,一切都会正常工作(已排除)。
然后我修改了.git/info/exclude,然后就太晚了。 Git 不再考虑对 .git/info/exclude 的更改。
所以问题是:
- 如何让 Git 在签入时接受排除文件中的更改? (我尝试再次运行 git add . ,但这没有帮助)
- 假设我签入了要排除的目录(或文件)。 达到我想要的状态最少需要多少步? (排除该文件)。
I usually do this:
git init
git add .
git commit .
And then I realize that it's about to add my nbproject directory, which I want excluded/ignored. Sometimes, I even check in this directory. Had I added it to .git/info/exclude before running git add .
, everything would have worked fine (it's excluded).
So then I modify .git/info/exclude and then it's too late. Git no longer respects changes to .git/info/exclude.
So the questions are:
- How can I get Git to take up the changes in the exclude file in the checkin? (I tried running
git add .
again, which doesn't help) - Let's say I check in a directory (or file) that I want excluded. What is the least number of steps to get to the state I want?
(with the file excluded).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要删除已添加但未提交的文件,请使用如下命令:
这将从索引中删除该文件,但不会触及磁盘上的文件。
要从最近提交中删除一个或多个文件,请使用上面的
git rm --cached
命令,然后使用git commit --amend
。To remove a file that you have added but not committed, use a command like this:
This will remove the file from the index, but not touch the file on disk.
To remove a file (or files) from the most recent commit, use the above
git rm --cached
command followed bygit commit --amend
.