git – How to clone a second branch using the same directory as the first cloned branch?


I have a repository with several branches, I cloned a specific one and worked on it.

Later came the need to work on another branch of the same project, is there a way to clone it to the same folder as the first branch?

  • Note: as the repository is very large, it takes a long time to clone the entire project at once.


You can use the command, to work directly with the branch:

git checkout -b [branch] [nomeremoto]/[branch]

Or if you want to create another branch and merge it.

Creating the branch:

git branch nomebranch

Giving a checkout:

git checkout nomebranch

Giving merge:

git merge nomebanchdesjado
Scroll to Top