0

I am not sure I understand the logic clearly or I am am using git wrongly. If my partner makes cnahges in his local repo and pushes changes to a secondary branch , as we dont use the master main branch, how do I get his changes into my system. Thank you!

Bill Hileman
  • 2,798
  • 2
  • 17
  • 24
  • Possible duplicate of [Git: getting changes from another branch](https://stackoverflow.com/questions/3124601/git-getting-changes-from-another-branch) – Raman Mishra Sep 04 '18 at 11:41
  • You can do git pull, git merge origin/secondary branch to merge changes in the secondary branch. on git command line. – Raman Mishra Sep 04 '18 at 11:42
  • The "duplicate" is relevant but **DON'T** immediately perform `git merge` into *master* as indicated. This is not what the user want to do and it will be complicated to revert these actions for a non-experimented user. – Obsidian Sep 04 '18 at 11:53

1 Answers1

0

First you can do

git branch -avv

… to display a fully qualified detail of every local and remote branches your repository has knowledge of. At this stage, you should be able to see your own "master" branch and the remote one "origin/master". At first, they're technically independent BUT yours has been automatically set up by git clone to "follow" the remote one, allowing you to fetch/push/pull it. At any time, you can alter this configuration if you wish so, or manually declare new branches then set them up to follow another ones, even if they're not named the same way.

Then:

git fetch origin <branchname>

… assuming here that "origin" is the name of your declared remote repository, which is the name chosen by default when performing git clone. Or even:

git remote update

which would update the state of every declared remote repository, which in turn includes an update (implying a fetch) of every branch for each of them.

At this point, you should now see your colleague's remote branch. You can check it out in detached mode with git checkout origin/<branchname> or simply browsing its content with git log origin/<branchname>. But if you simply type :

git checkout <branchname>

Git will look for a local branch named this way. It won't find it BUT will fail back on the remote one. It will therefore assume that it's supposed to be the homolog one, then automatically create the local one, set it up to track to remote one, check it out in your working directory and print an explicit message to state about all of this.

Do another git branch -vva to see the changes.

Obsidian
  • 3,719
  • 8
  • 17
  • 30