Search code examples
gitgithubgithub-for-mac

How do I take the latest from another branch and then do a commit


Pardon me as I am a newbie to git. I understand SVN and if someone can explain it in terms of SVN, that will be great. Currently, I am using the tool GitHub for Mac. But, I am open to using the terminal.

I am working locally on a master branch. A colleague has made changes in another branch. Before I checkin my changes, I want to merge that branch into my local master branch and then commit. How do I go about it?


Solution

  • Assuming your colleague has pushed his changes to the central repository, you could do this

    git fetch
    

    Git fetch will get your colleagues changes to your local repository.

    Let's say the branch he worked on was called other_branch, then you can do this to merge his changes to your current branch:

    git merge origin/other_branch
    

    When you are done merging you can push your changes to the central repository:

    git push