记录一个连续修改.gitignore文件的过程

情景:遇到一个问题,要修改.gitignore 文件,将某一个文件夹忽略,但是
由于第一次没有修改正确,导致需要再次修改.gitignore 文件,由于这种情况并不少见,所以这里将过程记录下来

首先执行 .gitignore 文件,然后,执行

git rm -r --cached .
git add .

这时候发现,这次修改.gitignore 文件并没有达到预期的效果,
所以需要再此修改.gitignore 文件
再次修改过之后
执行

git rm -r --cached .

报错

error: the following file has staged content different from both the
file and the HEAD:
.gitignore
(use -f to force removal)

这里就根据提示执行

git rm -r --cached . -f

然后执行

git add .

然后再通过sourceTree 查看,是符合自己预期的

通过以上过程,多次修改如下

1 git rm -r --cached .
2 git add .

再修改

扫描二维码关注公众号,回复: 15057576 查看本文章

3 git rm -f --cached . -f
4 git add .

猜你喜欢

转载自blog.csdn.net/LIUXIAOXIAOBO/article/details/130537019