1

I have been working a local repository synced with a GitHub repository.

Recently our GitHub repository has a newly created branch release.

Locally, I first run git checkout release, which seems successful, and says:

Branch release set up to track remote branch release from origin.

Switched to a new branch 'release'

I heard that when release doesn't exist locally, git checkout release will pull from a branch also named the same as release from repository origin. So I think running git pull isn't necessary. But to my surprise, when I run git pull, it tells me that

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.

Why does git pull tell me it will merge? What is the reason for the merge?

What shall i do then?

  • Which local branch were you in when you ran git pull? Have you committed anything since you ran git checkout release? – Stephen Kitt May 17 '17 at 15:44
  • When i ran git pull, I was on release branch because I ran git checkout release earlier. There was no unstaged or uncommited changes before running git checkout release and between it and git pull. What do you suspect is the reason that causes merge in git pull? – Tim May 17 '17 at 15:47
  • A merge on git pull indicates that the local and remote branches have diverged. I wasn’t asking about unstaged or uncommitted changes (they produce a different error); so I’ll ask again: have you committed anything since you ran git checkout release? – Stephen Kitt May 17 '17 at 16:05
  • No i didn't commit any thing since git checkout release. – Tim May 17 '17 at 16:57
3

A merge on git pull indicates that the local and remote branches have diverged. That means that there are new commits in both branches (local and remote) since the last time they were in sync.

To integrate the new remote commits into your local branch without a new merge commit, kill your current git command, then run git merge --abort to abort the merge. Then run git rebase origin/release to rebase your local commits on top of the new remote commits.

git pull -r

will avoid this in the future (it instructs git pull to rebase instead of merging).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.