2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > git 解决ahead behind分叉以及删除远端commit

git 解决ahead behind分叉以及删除远端commit

时间:2022-09-13 23:42:57

相关推荐

git 解决ahead behind分叉以及删除远端commit

解决ahead / behind

先reset到ahead,然后退回到分叉,再checkout 远端的behind

如果要删除本地的commit, 先到本地的最前端, 然后再用下面的命令

If you want to fix up your latest commit, you can undo the commit, and

unstage the files in it, by doing:

git reset HEAD~1 This will return your repository to its state before

the git add commands that staged the files. Your changes will be in

your working directory. HEAD~1 refers to the commit below the current

tip of the branch.

If you want to uncommit N commits, but keep the code changes in your

working directory:

git reset HEAD~N If you want to get rid of your latest commit, and do

not want to keep the code changes, you can do a “hard” reset.

git reset –hard HEAD~1 Likewise, if you want to discard the last N

commits, and do not want to keep the code changes:

git reset –hard HEAD~N

2.删除远端commit

先退回到正确的local commit然后

git push –force

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。