Fetch a remote branch that doesn’t exist locally using git

Say you are working on not your normal computer and are working on a branch that isn’t quite ready to get merged with the official git repo for the codebase. Here’s what you can do:

[bash]
git push SOME_OTHER_ORIGIN branch_name –tags –set-upstream
[/bash]

Then, when you get back to the computer you normally work on, you can do this:

[bash]
git fetch SOME_OTHER_ORIGIN

git checkout -b branch_name
# which will switch you to that branch

$ git fetch SOME_OTHER_ORIGIN branch_name
Password for ‘https://you@git.place’:
From https://git.place/….
* branch branch_name -> FETCH_HEAD

# Check this is what you want:
$ git log ..FETCH_HEAD

# if it is, then
$ git merge –no-ff FETCH_HEAD | more
[/bash]

NOTE: You might need to hide some local files that get gotten in the 1st place.