1、檢查分支的提交記錄,找出基准點;
2、將基准點以后的提交revert。
3、重新提交,相當於合並commit。
git reset --hard 和 git reset --soft區別
1、二者區別:
git reset –-soft:回退到某個版本,只回退了commit的信息,不會恢復到index file一級。如果還要提交,直接commit即可;
git reset -–hard:徹底回退到某個版本,本地的源碼也會變為上一個版本的內容,撤銷的commit中所包含的更改被沖掉;
————————————————
版權聲明:本文為CSDN博主「木林森淼」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/yangfengjueqi/java/article/details/61668381
git reset --hard f34701c1
你沒合並之前,可以把之前所有提交合並 , 用 git reset HEAD~5, 表示之前5次提交都撤銷,然后可以重新commit了;注意在checkout新分支操作;
commit 4e055349d8f408c4c7dec61f7ad1d5f44a14ec55
Date: Thu Jun 4 15:07:22 2020 +0800
commit f05d8a6d596da6f709b05acd39cfdabf4cb30767
Date: Fri Jun 12 11:04:53 2020 +0800
git 查看單個分支提交歷史
如果dev-webpack從dev切出來的
可以用
git log dev..dev-webpack
查看單獨的dev-webpack提交歷史
git reset --soft 42a5195fb94bd80b020ae0c4bac292a414720014
git reset --soft f05d8a6d596da6f709b05acd39cfdabf4cb30767
On branch development
Your branch is up to date with 'origin/development'.
Changes not staged for commit:
modified: Pod/Classes/Sources/hhhhh/sssss.m
no changes added to commit
➜ google git:(development) ✗
➜ google git:(development) ✗
➜ google git:(development) ✗ git add . -u
➜ google git:(development) ✗ git status
On branch development
Your branch is up to date with 'origin/development'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: Pod/Classes/Sources/dddd/dddde.m
➜ google git:(development) ✗ git commit -m'1552135 代碼commit規范檢查 obsoletes:1905e94'
[development 5f956174] 1552135 代碼commit規范檢查 obsoletes:1905e94
1 file changed, 1 insertion(+), 1 deletion(-)
➜ google git:(development) git checkout -b feature/xxxx
Switched to a new branch 'feature/xxxx'
➜ google git:(feature/xxxx) git push origin feature/xxxx:feature/xxxx