我可以告诉git忽略被修改(删除)但不应提交的文件吗?
情况是我在repo中有一个子目录,其中包含我根本不感兴趣的东西,因此我将其删除以防止它出现在自动完成等中(在IDE中) .
但是现在,如果我将该文件夹添加到.gitignore,只是没有任何变化,所有内容都显示为被git status删除 .
有没有办法让git忽略它?
(或者,因为我正在使用git-svn,我可以将更改提交到本地git并确保它们不会传递给svn repo吗?)
检查git-update-index man page和--assume-unchanged位和相关 .
当我遇到你的问题时,我会这样做
git update-index --assume-unchanged dir-im-removing/
或特定文件
git update-index --assume-unchanged config/database.yml
一个更新更好的选项是 git update-index --skip-worktree ,它不会在硬复位或拉动的新变化时丢失 .
git update-index --skip-worktree
请参阅http://schacon.github.com/git/git-update-index.html的手册页
并在http://fallengamer.livejournal.com/93321.html进行比较
跟踪文件必须首先从索引中删除它们 . 添加 .gitignore 忽略您不想要的目录,然后删除它们,并删除任何带有 git rm --cached 的落后者 .
.gitignore
git rm --cached
我通常做的是
git stash git what-else git stash apply git stash clear
使用此代码
git update-index --assume-unchanged file-name
5 回答
检查git-update-index man page和--assume-unchanged位和相关 .
当我遇到你的问题时,我会这样做
或特定文件
一个更新更好的选项是
git update-index --skip-worktree
,它不会在硬复位或拉动的新变化时丢失 .请参阅http://schacon.github.com/git/git-update-index.html的手册页
并在http://fallengamer.livejournal.com/93321.html进行比较
跟踪文件必须首先从索引中删除它们 . 添加
.gitignore
忽略您不想要的目录,然后删除它们,并删除任何带有git rm --cached
的落后者 .我通常做的是
使用此代码