git commit -n,git 解決ahead behind分叉以及刪除遠端commit

 2023-11-11 阅读 19 评论 0

摘要:解決ahead / behind 先reset到ahead,然后退回到分叉,再checkout 遠端的behind git commit -n、如果要刪除本地的commit, 先到本地的最前端, 然后再用下面的命令 If you want to fix up your latest commit, you can undo the commit, and unstage the fi
  1. 解決ahead / behind

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

git commit -n、如果要刪除本地的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

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/2/171282.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息