Reputation: 508
I am facing a weird issue while trying to rebase a branch with master branch. Scenario is as given below:
git checkout git checkout <sha>
git switch -c feature_branch
git push origin feature_branch
feature_branch
compared to master
.feature_branch
with the master
git rebase master
. First, rewinding head to replay your work on top of it...
Fast-forwarded feature_branch to master.```
feature_branch
has been over-written by master
and no conflicts were shown during the rebase.Could anybody please explain what is going on here. It would be really helpful, as I maybe missing some basics here.
Thank you
Upvotes: 0
Views: 184
Reputation: 265161
git rebase <target> [<source>]
will take all commits from source
(defaults to your current branch) and copy them one-by-one to the target. If source is fully contained in target (i.e. all commits of source are also in target), then there are no commits to copy. Rebase is effectively a no-op, with the exception of moving the branch label of source to the same commit as target.
Think of it as commits, as shown by git log --oneline --graph source...target
(3 dots), not as changes as shown by git diff source target
. You can preview the commits that would be rebased by running git log --oneline target..source
—if the output is empty, there are no commits to rebase (source is fully contained in target).
If you want to duplicate the commit on master, you have (at least) three options, depending on the exact content of the commits:
git checkout master
git cherry-pick bug_fix_commit
reverting the revert:
git checkout master
git revert revert_of_bug_fix_commit
Instruct rebase to not compute the range of commits automatically, but manually supply the range to copy:
git rebase --onto master feature_branch^ feature_branch
Upvotes: 1