The use case is following
I pull from the development branch then I make some code changes and push then
After few days I come back and do to a git status, this shows that I am ahead of the master branch by 1 commit, obviously I haven't pulled from the master for a couple of days
Now before I make my changes I decide to do a git pull with rebase , git pull --rebase origin master
The question is: will the commit that I had in my local repo branch go on top of the master or since I had already pushed it I will simply get to the tip of the global master/remote branch?
I am new to concept of rebasing so please help explain this.
Let's consider the following.
A few days ago your local master and origin/master were both in sync and each had commits
A,BandC. At some point you committedXin your local master. And concurrently others pushed commitsD,EandFto origin/master.At this point if you run
git pull --rebase origin master, will pull all commits from the origin/master as is and the commitXwill be replayed over top ofFand a new commit id will be generatedX'.The new commit graph will look like:
So yes, the old commit
Xwill be rebased at the top of your local master as commitX'.EDIT:
In this case, after pushing your commit X, both your local repository and origin/master will be in sync.
After few days the commits
D,EandFare pushed by others to the origin/master. The commit graph will then look like this:Now if you run
git pull --rebase origin masterit will give identical results to thegit pull origin mastercommand, because there is nothing to rebase from. You do not have have any commits ahead of origin/master. At the end of this command your graph will look like this:Since your commit
Xwas already in origin/master, it will not be replayed on top ofD,EandF.