这是我的存储库:https://github.com/quinnliu/WalnutiQ
我在.gitignore文件中添加了.gradle&build /。但是,当我进行此更改时,我只想从我的存储库中而不是本地删除.gradle文件和build /文件夹。我该怎么办?
使用git rm --cached
从索引中删除文件,但从工作树中删除文件。提交,然后推送。
请注意,它们仍将保留在您的提交历史记录中。将它们完全从历史中删除是另一回事,更复杂。
$ git clone https://github.com/quinnliu/WalnutiQ.git
$ cd WalnutiQ
$ git rm -r --cached build .gradle
$ ls -a
...
build
...
.gradle
...
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: .gradle/1.10/taskArtifacts/cache.properties
# deleted: .gradle/1.10/taskArtifacts/cache.properties.lock
# deleted: .gradle/1.10/taskArtifacts/fileHashes.bin
# deleted: .gradle/1.10/taskArtifacts/fileSnapshots.bin
# deleted: .gradle/1.10/taskArtifacts/outputFileStates.bin
# deleted: .gradle/1.10/taskArtifacts/taskArtifacts.bin
# deleted: build/libs/WalnutiQ.jar
# deleted: build/tmp/jar/MANIFEST.MF
#
[在.gradle
上添加.gitignore
后,我只是使用