0

Here is a scenario.

There is the original main develop Branch on the server along with a Version Branch. Both the develop branch has a fix (1_otherFix Branch) and the version Branch has (2_otherFix Branch). Both fixes have been merged.

Server

develop Branch (Original)
---------------------------------------------------------------
     \                             \ 1_otherFix Branch /
      \                             \-----------------/
       \ versionX Branch
        \------------------------------------------------------
                        \ 2_otherFix Branch /
                         \-----------------/          

My Environment

I created a clone of that main develop branch (myDevelop) which a version branch (myVersionX) is generated via a checkout. (git checkout versionX).

I then created a new branch (myFix) off of the myVersionX branch.

myDevelop Branch (clone)
---------------------------------------------------------------
      \                             
       \ myVersionX Branch
        \------------------------------------------------------
               \
                \ myFix Branch
                 \---------------------------------------------

The objective is to update the clone, my main develop branch (myDevelop), and my version branch (myVersionX) as well as my fix branch (myFix) so that they all include the 2 merged fixes from the server (1_otherFix Branch) and (2_otherFix Branch).

How do I get all 3 branches in my environment updated using "git pull"?

Can I do a "git pull" from (myFix) branch to have it update all 3?

myDevelop Branch (clone)
---------------------------------------------------------------
      \                             
       \ myVersionX Branch
        \------------------------------------------------------
               \
                \ myFix Branch
                 \---------------------git pull------------------

Do I have to navigate to each branch and do a "git pull" ?

myDevelop Branch (clone)
------------------------------1 - git pull---------------------
      \                             
       \ myVersionX Branch
        \------------------------2 - git pull-------------------
               \
                \ myFix Branch
                 \-------------------3 - git pull-----------------

Do I have to navigate to each branch and do a "git pull" with the specific name ?

myDevelop Branch (clone)
------------------------------1 - git pull develop------------------
      \                             
       \ myVersionX Branch
        \------------------------2 - git versionX-------------------
               \
                \ myFix Branch
                 \-------------------3 - git pull-----------------

Can I do all 3 pulls from myFix branch?

myDevelop Branch (clone)
---------------------------------------------------------------
      \                             
       \ myVersionX Branch
        \------------------------------------------------------
               \
                \ myFix Branch
                 \---------------------git pull develop-------------
                                       git pull versionX
                                       git pull

Is there a simpler way to get all 3 updated?

isherwood
  • 58,414
  • 16
  • 114
  • 157
Unhandled Exception
  • 1,427
  • 14
  • 30

1 Answers1

3

Yes, you need to checkout each branch and to merge the original develop branch.

Fetch the remote that is "hosting" the original develop branch first to ensure that your local GIT repository is aware of changes on this remote, and then, git checkout each of your 3 branches and perform a git merge myRemote/develop.

As a side note, I never recommend to use git pull as it doesn't really help in understanding GIT under the hood (even though it's just a git fetch + git merge).

MeuhMeuh
  • 826
  • 6
  • 26
  • Does that mean the same command "git merge myRemote/develop" would be used on each branch or would the merge command vary depending upon which branch you are on? – Unhandled Exception Mar 12 '20 at 13:21
  • The command is the same. You're just specifying the source of the merge, be it a branch name, commit hash, or tag. – isherwood Mar 12 '20 at 13:46
  • If I did a "git merge develop" instead of "git merge origin/develop" is there a difference? – Unhandled Exception Mar 12 '20 at 15:20
  • Yes, there is a tiny difference: what you are merging when doing a "git merge develop" is your local branch. You may, for instance, have added commit that you did not push to origin. On the contrary, if you perform a "git merge origin/develop", you are telling Git "hey, please merge the commits that you looked up for me the last time that I did a "git fetch"". It may not be up to date from origin (this is why you should fetch for some changes origin before doing it by doing a git fetch). – MeuhMeuh Mar 31 '20 at 14:16