git常见问题
[TOC] 1.git删除文件 当我们想要删除某个文件,直接删除是没有用的. [root@vultr hexo]# git status # On branch master nothing to commit (working directory clean) [root@vultr hexo]# rm source/_posts/test.txt rm: remove regular empty file `source/_posts/test.txt'? y [root@vultr hexo]# git status # On branch master # Changed but not updated: # (use "git add/rm <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # deleted: source/_posts/test.txt # no changes added to commit (use "git add" and/or "git commit -a") [root@vultr hexo]# git add . [root@vultr hexo]# git commit -m "delete test file " # On branch master # Changed but not updated: # (use "git add/rm <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # deleted: source/_posts/test.txt # no changes added to commit (use "git add" and/or "git commit -a") 直接使用rm 删除的仅仅是工作区的文件,并没有删除暂存区,所以commit 不会生效. 由于平时使用基本都是修改或者增加新文件,大家习惯用 git add 命令,而忽略了 git rm , 其实在git status 都有提示,仔细看看就知道了. ...