.gitignore可以忽略没有加入版本库中的文件或者文件夹,但是已经加入到版本库的,.gitignore是无用的。
1,git rm 可以将文件和文件夹从版本库中删除,但是本地也会删除。
2,git rm --cache 可以将文件和文件夹从版本库中删除,但是本地会保留
MacBook-Pro:test zhangying$ git rm --cache aaa //删除,本地保留 rm 'aaa' MacBook-Pro:test zhangying$ git commit -m "test" //提交到本地库 [master 07983fc] test 1 file changed, 4 deletions(-) delete mode 100644 aaa MacBook-Pro:test zhangying$ git push //提交远程库 Counting objects: 2, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (2/2), 229 bytes | 0 bytes/s, done. Total 2 (delta 1), reused 0 (delta 0) To 192.168.0.5:root/test.git afd326d..07983fc master -> master MacBook-Pro:test zhangying$ ls //查看一下,本地文件存大 1 2 aaa bbb hao.txt index.php mas test1 MacBook-Pro:test zhangying$ vim aaa //修改一下 MacBook-Pro:test zhangying$ git status //查看一下状态,没变化,已忽略 On branch master Your branch is up-to-date with 'test/master'. nothing to commit, working tree clean
转载请注明
作者:海底苍鹰
地址:http://blog.51yip.com/other/1951.html