Sawyer
Sawyer

Reputation: 15917

git diff shows difference after git pull from a branch

I have a dev branch and a bugfix/a branch. I want to sync up my bugfix/a with dev, so I do a

git pull origin dev 

from my bugfix/a branch, but after that, I still see git diff shows differences:

git diff --name-only dev..bugfix/a

why git pull doesn't merge all the changes from dev to my branch?

Upvotes: 2

Views: 1137

Answers (1)

Anshul Goyal
Anshul Goyal

Reputation: 76907

Are you sure your dev branch is up to date?

When you do git pull origin dev on another branch, only that other branch is getting updated, not the local dev branch.

If you will checkout your dev branch and if it is a tracking branch, it will show a message on the lines of branch is behind by so many commits.

Even if it is not a tracking branch, you will still need to update your dev branch locally so that it matches the changes on the origin branch.

In future, you can avoid this confusion by checking out dev, pulling in the changes in dev, and then checking out your bugfix branch, and merging changes there:

  • git checkout dev && git pull origin dev
  • git checkout bugfix/a && git merge dev

Upvotes: 1

Related Questions