1
我在中央远程存储库中有一些文件。我曾经犯过这些事。他们不需要被追踪了。我将它们添加到我的.gitignore文件中。但我仍然需要他们在我本地的回购,为我的本地网站。从远程回购中删除提交的文件,但保留它们在本地
我该怎么做,让他们离开我的远程仓库,但仍然保留在我的本地存储库?
我在中央远程存储库中有一些文件。我曾经犯过这些事。他们不需要被追踪了。我将它们添加到我的.gitignore文件中。但我仍然需要他们在我本地的回购,为我的本地网站。从远程回购中删除提交的文件,但保留它们在本地
我该怎么做,让他们离开我的远程仓库,但仍然保留在我的本地存储库?
[编辑]
你必须从混帐与git rm --cached foo.txt
删除它们。这会将它们标记为已在回购中删除,但不会实际删除它们。
所以,这是一个完整的打印出来:
master!git> git status
On branch master
nothing to commit, working directory clean
master!git> ls -la
total 0
drwxr-xr-x 4 creynder staff 136 Apr 13 13:14 .
[email protected] 52 creynder staff 1768 Apr 13 13:14 ..
drwxr-xr-x 12 creynder staff 408 Apr 13 13:14 .git
-rw-r--r-- 1 creynder staff 0 Apr 13 13:14 foo.txt
master!git> git rm --cached foo.txt
rm 'foo.txt'
master!git *> git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: foo.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
foo.txt
master!git *> git commit -m 'Delete foo.txt'
然后添加 “foo.txt的” 来的.gitignore。