# On branch master# Your branch and 'origin/master' have diverged,# and have 3 and 3 different commit(s) each, respectively.
然后我不得不多次输入相同的git reset命令。每次我这样做时,消息都会更改一个,如下所示。
> git reset --hard HEAD^HEAD is now at [...truncated...]> git status# On branch master# Your branch and 'origin/master' have diverged,# and have 3 and 3 different commit(s) each, respectively.> git reset --hard HEAD^HEAD is now at [...truncated...]> git status# On branch master# Your branch and 'origin/master' have diverged,# and have 2 and 3 different commit(s) each, respectively.> git reset --hard HEAD^HEAD is now at [...truncated...]> git status# On branch master# Your branch and 'origin/master' have diverged,# and have 1 and 3 different commit(s) each, respectively.> git reset --hard HEAD^HEAD is now at [...truncated...]> git status# On branch master# Your branch is behind 'origin/master' by 3 commits, and can be fast-forwarded.
git log --oneline feature-1a1b2c3d4 Merge branch 'dev' into 'feature-1' <-- the merge you want to undoe5f6g7h8 Fix NPE in the Zero Point Module <-- the one before the merge, you probably want this one
Check it out (go back in time):
git checkout e5f6g7h8
Create a new branch from there and check it out:
git checkout -b feature-1
Now you can restart your merge:
Merge: git merge dev
Fix your merge conflicts.
Commit: git commit
When you're satisfied with the results, delete the old branch: git branch --delete feature-1
git checkout master##to delete one branch, you need to be on another branch, otherwise you will fall with the branch :)
git branch -D developgit checkout -b develop origin/develop
# Checkout a given commit.# Doing so will result in a `detached HEAD` which mean that the `HEAD`# is not pointing to the latest so you will need to checkout branch# in order to be able to update the code.git checkout <commit-id>
# create a new branch forked to the given commitgit checkout -b <branch name>
# This will destroy any local modifications.# Don't do it if you have uncommitted work you want to keep.git reset --hard 0d1d7fc32
# Alternatively, if there's work to keep:git stashgit reset --hard 0d1d7fc32git stash pop# This saves the modifications, then reapplies that patch after resetting.# You could get merge conflicts if you've modified things which were# changed since the commit you reset to.