bash环境GIT仓库基本操作(2)

来源:互联网 发布:csol大刀优化软件 编辑:程序博客网 时间:2024/06/06 00:46

1、丢弃工作区的修改

$ git checkout -- file  //三个过程,工作区修改文件---添加文件到暂存区---提交文件到版本库。此过程类似于编辑环境下的撤销到上一次的添加或者提交的状态
例:
$ git checkout -- readme.txt
2、撤消暂存区的修改到工作区

$ git reset HEAD readme.txtUnstaged changes after reset:M       readme.txt
3、从版本库中删除文件

$ git rm test.txtrm 'test.txt'$ git commit -m "remove test.txt"[master d17efd8] remove test.txt 1 file changed, 1 deletion(-) delete mode 100644 test.txt
4、用版本库里的版本替换工作区里的版本

$ git checkout -- test.txt

0 0