Last active
May 31, 2019 02:12
-
-
Save dospuntocero/f87b6c316f667dc96d8928739fa43262 to your computer and use it in GitHub Desktop.
How to switch to a different remote branch in git Ask Question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
first, just input following command in the terminal: | |
git branch --all | |
And then you will see the all the branches on local and remote. Something like this: | |
*master | |
remotes/origin/develop | |
remotes/origin/master | |
remotes/origin/web | |
remotes/origin/app | |
Let's pretend you want to switch to the remotes/origin/develop branch. Type following: | |
git checkout remotes/origin/develop | |
Then type git branch --all again to find this: | |
*(detached from remotes/origin/develop) | |
master | |
remotes/origin/develop | |
remotes/origin/master | |
remotes/origin/web | |
remotes/origin/app | |
And then just do: | |
git checkout -b develop | |
From now on, you are working on the remotes/origin/develop branch exactly. | |
also you can pull changes directly using the upstream method | |
git branch --set-upstream-to=origin/develop develop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment