打标签
git tag -m "Say bye-bye to all previous practice." old_practice //引号里是注释
本地删除不是真的删除,对暂存区和版本库,没有任何影响
rm 删除工作空间内容
git ls-files 查看 暂存区(版本库)中还是有删除的内容
可以使用git checkout -- <file> 找回刚刚删除的文件
真正删除 ,在执行了rm 后 执行
$ git rm detached-commit.txt hack-1.txt new-commit.txt test.ini welcome.txt
rm 'detached-commit.txt'
rm 'hack-1.txt'
rm 'new-commit.txt'
rm 'test.ini'
rm 'welcome.txt'
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: detached-commit.txt
# deleted: new-commit.txt
# deleted: test.ini
# deleted: welcome.txt
#
执行git rm 后再执行 git commit 就真删除了
$ git commit -m "delete trash files.(useing: git rm)"
[master 124a538] delete trash files.(useing: git rm)
4 files changed, 5 deletions(-)
delete mode 100644 detached-commit.txt
delete mode 100644 new-commit.txt
delete mode 100644 test.ini
delete mode 100644 welcome.txt
历史版本中查看删除的文件
$ git ls-files --with-tree=HEAD^
detached-commit.txt
new-commit.txt
test.ini
welcome.txt
历史版本中查看删除文件的内容
$ git cat-file -p HEAD^:welcome.txt
Hello .
Nice to meet you
快速标记删除实验
版本库恢复上一次提交 暂存区也恢复上一次 工作区也恢复上一次提交
$ git reset --hard HEAD^
HEAD is now at a7e643d Merge commit 'dcdf192'
恢复保存的进度 加-q是安静模式
git stash apply -q
删除本地所有文件 依然只删除工作区的
rm *.*
$ git status -s
D detached-commit.txt
AD hack-1.txt
D new-commit.txt
D test.ini
D welcome.txt
然后执行 git add -u 将工作区中修改或者删除的被版本库跟宗的文件 的变更记录到暂存区
$ git add -u
查看状态,全部标记为下次提交都删除
$ git status -s
D detached-commit.txt
D new-commit.txt
D test.ini
D welcome.txt
提交删除
$ git commit -m "delete trash files.(useing: git add -u)"
[master 509a15e] delete trash files.(useing: git add -u)
4 files changed, 5 deletions(-)
delete mode 100644 detached-commit.txt
delete mode 100644 new-commit.txt
delete mode 100644 test.ini
delete mode 100644 welcome.txt