已经有一个文件提交。
我想添加文件.gitignore。我想保留文件。
例如]
$ git ls-files
foo
$ echo "foo" > .gitignore
$ echo "test" >> foo
$ git status
# On branch master
# Your branch is up to date with 'origin/master'.
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: foo
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .gitignore
#
no changes added to commit (use "git add" and/or "git commit -a")
您可以看到,foo文件状态已更改为“已修改”。我想不被修改状态。如何在不删除的情况下将foo文件添加到.gitignore。
已经回答不是我想要的。我想要的不是本地设置。我想要每个开发人员都不使用'git update-index --assume-unchanged path / to / file.txt'
的方法从git中删除foo:
git rm --cached foo
将您的.gitignore文件与此删除操作一起提交:
git add .gitignore
git commit