移除文件说明要从 Git 中移除某个文件,就必须要从已跟踪文件清单中移除(确切地说,是从暂存区域移除),然后提交。 可以用 git rm 命令完成此项工作,并连带从工作目录中删除指定的文件,这样以后就不会出现在未跟踪文件清单中了。
git rm Git 中用来删除文件的命令。它不仅会删除工作区中的文件,还会将文件的删除操作记录到 Git 的暂存区(staging area)。如果你删除了文件但没有执行 git rm,Git 只会认为这个文件在工作区被删除,但不会将其删除操作记录到暂存区,直到你手动添加该变化。
直接删除被跟踪文件的效果rm A.cgit statusOn branch masterYour branch is up to date with 'origin/master'.Changes not staged for commit: (use "git add/rm
git rm B.crm 'B.c' git statusOn branch masterYour branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits)Changes to be committed: (use "git reset HEAD
touch C.c## 新建一个文件echo "this is C.c file" >> C.cgit add C.cgit statusOn branch masterYour branch is up to date with 'origin/master'.Changes to be committed: (use "git reset HEAD
touch D.croot@osboxes:/home/user/my_project# echo "this is D.c file" >> D.croot@osboxes:/home/user/my_project# git add D.croot@osboxes:/home/user/my_project# git statusOn branch masterYour branch is up to date with 'origin/master'.Changes to be committed: (use "git reset HEAD
Ahmedabad