1

I worked on 'dev' branch of a remote repo.

The 'dev' branch was then merged with 'master' branch.
But along with the merge, the 'master' branch also had its own changes, aka commits.
Which means, master was commited few times before 'dev' being merged into it.

Now when I do 'git pull' staying in 'dev' branch, what is that going to do?

Will it pull all updated data of remote 'master' branch to my local 'master' branch as well ?
Or will I have to checkout to 'master' branch of my local repo and then do the git pull ?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
bijaykumarpun
  • 677
  • 4
  • 9

2 Answers2

1

Now when I do 'git pull' staying in 'dev' branch, what is that going to do ? Will it pull all updated data of remote 'master' branch to my local 'master' branch as well ?

No: master has a new "merge commit" from the merge operation of dev to master.

But dev itself has not changed. Its HEAD has not moved.
A pull (fetch + merge) of the dev branch will result in dev history only being updated. (even though the fetch part would, with a default refspec, fetch the history of all branches)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • ok so git pull from 'dev' branch will update dev's history only. That will mean i will have to go to the 'origin' branch and pull from there. Am i right ? And how do i update all branch at once? that possible ? And thanks ! – bijaykumarpun Apr 11 '19 at 04:39
  • @developer type in your repo `git config remote.origin.fetch`: if you see ` +refs/heads/*:refs/remotes/origin/*`, that will fetch all branches. But the merge part of a pull will update only dev. To update *all* local branches: https://stackoverflow.com/a/33137677/6309 – VonC Apr 11 '19 at 04:44
0

git pull will only update the current branch from where you are executing this command.

For detailed info: Visit https://git-scm.com/docs/git-pull

To fetch all remotes, you can run this command

git pull --all
vinodsaluja
  • 573
  • 6
  • 15