git进行普通推送和推送失败后对应的版本回退命令

版权声明:转载请注明文章来源 https://blog.csdn.net/Crystal_1999/article/details/86073682

进行普通推送:
1、 git add . 提交错误,要回到add提交之前,但需要保留源码: git reset -mixed HEAD
2、 git commit -m “注释” 提交错误,要回到commit提交之前,但需要保留add 的内容和源码: git reset -soft HEAD
3、 git push 提交错误,要回到push提交之前, 本地的源码会变为上一个版本的内容 git reset --hard HEAD

其中 HEAD表示 当前版本。
HEAD^表示上次提交,HEAD ^ ^ 表示前两次提交……
HEAD~ 1表示上次提交,HEAD~2表示前两次提交……
同时可以用commit_id的开头表示版本HEAD <commit_id>

git log看到提交历史
git relog 看到操作历史

创建并转到本地分支:git branch -b <branch_name>
本地分支和远程分支发生联系:git push origin(<远程仓库名>) <branch_name>

猜你喜欢

转载自blog.csdn.net/Crystal_1999/article/details/86073682
今日推荐