vim, git, aws and other three-letter words

Software Development Notes

git: your branch is ahead of 'origin/master' by 1 commit after pull

Git reports that:

Your branch is ahead of 'origin/master' by 1 commit (or X commits)

after you do the git pull origin master.

The sequence of actions:

The reason is that after the pull origin master the reference to the remote origin/master is not changed (still points to the older version) and only your local copy of the branch is updated.

The problem is that git pull origin master is the wrong command (unless you intentionally wanted to only update the local branch).

Solution: use git pull instead. It will fetch remote changes, update remote references and merge remote changes to your local branch. Or use git fetch. It will fetch remote references, but will not merge to your local branch, and you do it manually by running git merge origin/master.

To check the state, run:

git diff origin/master

It will show the difference and it should be the last master change.

To fix the problem, run:

git fetch origin

This will update git links to remotes.

If you have this problem then you likely wanted to just do git pull instead of git pull origin master.

Tags: git