git 取消修改,恢复版本常用命令

星期五, 2017-03-17 | Author: Lee | JAVA-and-J2EE, linux | 2,497 views

一并说下 常用的简单指令

1. >git clone xxxx.git
 
2. >git status
 
3. >git add *
 
4. >git commit -m "comment"
 
5. >git push
 
6. >git pull
 
上述是正常情况下的使用,下面为修改等
#取消对文件的修改。还原到最近的版本,废弃本地做的修改。
git checkout -- <file>
 
#取消已经暂存的文件。即,撤销先前"git add"的操作
git reset HEAD <file>...
 
#修改最后一次提交。用于修改上一次的提交信息,或漏提交文件等情况。
git commit --amend
 
#回退所有内容到上一个版本
git reset HEAD^
 
#回退a.c这个文件的版本到上一个版本  
git reset HEAD^ a.c  
 
#向前回退到第3个版本  
git reset –soft HEAD~3  
 
#将本地的状态回退到和远程的一样  
git reset –hard origin/master  
 
#回退到某个版本  
git reset 089c  
 
#回退到上一次提交的状态,按照某一次的commit完全反向的进行一次commit.(代码回滚到上个版本,并提交git)
git revert HEAD

文章作者: Lee

本文地址: https://www.pomelolee.com/1706.html

除非注明,Pomelo Lee文章均为原创,转载请以链接形式标明本文地址

一条评论 to git 取消修改,恢复版本常用命令

Lee
2018 年 05 月 16 日

Git放弃本地所有修改,强制更新
git fetch –all
git reset –hard origin/master
git fetch 只是下载远程的库的内容,不做任何的合并

git reset 把HEAD指向刚刚下载的最新的版本

Leave a comment

Search

相关文章

文章分类

Links

Meta