git rebase
is basically git merge
, but in a different way.
From a repo, I :
- create a branch
issue_adjust_threshold
- adjust the threshold
- make a commit
Adjust the threshold
- push to remote with
git push --set-upstream origin issue_adjust_threshold
- make a
pull request
But on PR page it tells me there is a conflict . So I check the commit history and find out the other case owner has made two commits to master
branch. I need to do git rebase
.
-
git checkout master
, checkout tomaster
branch -
git pull
, updatemaster
branch -
git checkout issue_adjust_threshold
, checkout toissue_adjust_threshold
branch -
git rebase -i master
, rebasemaster
toissue_adjust_threshold
- git tells there are conflicts with a file
xxx/MainTest.java
- fix the conflict,
git add xxx/MainTest.java
git commit -m "Adjust the threshold"
git push -f
If some rebase doesn't work well, this can undo it:
git reflog
git reset --hard HEAD@{n}
Refer to:rebase 01, rebase 02, resolve conflict 01, resolve conflict 02, resolve conflict 03, undo rebase.
网友评论