I use Git Bash for bitbucket. I have created a brunch and I pushed some commits, other people pushed commits in master. Now I am on a different machine. I want to clone or download the solution of the latest commit of my branch and not the master? How can I do that?
git-remote add To clone a branch without fetching other branches, you can use the git-remote add command with git-fetch. The following example first creates and initializes an empty git repository. Then it adds a remote named origin for the specified repository and fetches the specified branch from the origin.
There are two ways to clone a specific branch. You can either: Clone the repository, fetch all branches, and checkout to a specific branch immediately. Clone the repository and fetch only a single branch.
I think you are looking for the --branch
option to git clone
, which allows you to specify which branch is initially checked out in the cloned repository.
git clone --branch mybranch $URL/foo
is roughly equivalent to
git clone $URL/foo
cd foo
git checkout mybranch
cd ..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With