How to look at another developer's branch using git?

git

Solution

You don't need the second location, if it's the same repository that the other developer pushed their branch to, you can just fetch from that remote and then `git checkout <the developer's branch name>` to change the working directory to their code.

It's safest to have a clean `git status` when you try to check it out.

The process would be:

git fetch remotename
git checkout branchname

If the name matches, `git` will automatically set it to track the branch that the other developer has pushed.

Problem

I had a project where I was the only developer. Then a new developer joined the project and created his developer branch. I would like to create a separate place and download his branch so I can run his code from that new place to avoid any conflict. I made a new directory on my local computer. And I am thinking to do this command: ``` git checkout -b branch-name origin/branch_name ``` But I know it is kind of wrong because I need to check out the new trunk and branch together I guess? I am confused on what the correct practice is for doing this. Could someone please explain to me how this is commonly done? Thank you!

Original source

Related problems