Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT checkout branch via terminal

Tags:

git

github

Is it possible to checkout a branch using the command line (terminal on mac) knowing just:

ssh://[email protected]:8000/abc/somename.git
like image 545
CyberJunkie Avatar asked Dec 03 '22 13:12

CyberJunkie


2 Answers

You have to clone this repository first using

git clone ssh://[email protected]:8000/abc/somename.git

This will be creating a local working copy of this project and will be on the default branch of it what is probably 'master'

You can verify which branch you are on using

git status

If you want a list of the available branches (in the remote repo) execute

git branch -r

If you want another remote branch available on your local copy you can use

git checkout --track origin/remotebranchname

The --track parameter will tie your local branch and remote branch together so you won't have to be give it explicitly when pushing your code for example.

like image 116
David Katona Avatar answered Dec 11 '22 16:12

David Katona


Create the branch on your local machine and switch in this branch :

$ git checkout -b [name_of_your_new_branch] [name_of_the_origin_branch]
like image 32
Specter Avatar answered Dec 11 '22 17:12

Specter