Ok, if your manager ask you to checkout the project code from Git or GitLab, then he is basically old school and he is asking you to clone it, you can correct him saying – “no its not checkout the code, its clone the code, checkout has different meaning, it means – change the branch.”
So lets see how to clone a project.
Suppose we want to clone this project: https://gitlab.com/heapsteep/git-demo
As shown in the below pic, the project has 5 branches:
Create a folder in your local machine and go inside the folder, then right click and open Git Bash.
Then hit the below command:
git clone https://gitlab.com/heapsteep/git-demo.git
It will clone all the branches.
To change the current directory to git-demo:
cd <tab>
Now you will be inside git-demo folder and you can see the current branch would be master.
To see what are all branches that are cloned, hit the below command:
git branch -a
Then you will see something like below:
To change to a particular branch call checkout command:
git checkout US-101
And if you call git branch -a , you will see below screen:
How to clone a specific branch only?
In above example we saw how we do cloning all the branches and do checkout immediately to a specific branch. But it is advisable to clone only a single branch, so that it would save some space and time:
git clone -b <branch name> <remote-repo-url>