Question

I have a local branch where I haven't done any changes. Then I do

git checkout anotherbranch
# Switched to branch 'anotherbranch'
# Your branch is behind 'origin/anotherbranch' by 25 commits, and can be fast-forwarded.
# (use "git pull" to update your local branch)

So apparantly I need to pull to get all the latest changes. I do this

git pull origin anotherbranch

I expect now everything to be in sync, but it isn't because

git status
On branch anotherbranch
Your branch is ahead of 'origin/anotherbranch' by 2 commits.
(use "git push" to publish your local commits)

nothing to commit, working directory clean

Is this because the merge part of git pull added another two commits? However these commits does not show when I do git log. Instead on top are two commits made by another author. It feels wrong for me to push his two commits. Actually I don't want to push anything at all but just update my local branch. How can I do this? In case git pull was a mistake how can I revert it without producing alternative realities or other git horrors (I haven't pushed anything, except on another feature branch)

Was it helpful?

Solution

git status
On branch anotherbranch
Your branch is ahead of 'origin/anotherbranch' by 2 commits.
(use "git push" to publish your local commits)

It means that you have 2 commits that are not pushed.

As a best practice is good to run

git fetch

once in a while to get all the server metadata (updated deleted branches, new commits etc)

what is the results of this command:

git log --oneline

it will show you all the log with the commits so yu can see what is the problem

OTHER TIPS

Ok, so before I do git checkout anotherbranch I need to do git rebase origin/anotherbranch is nothing wrong with doing this because I was on a private feature branch.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top