I want to copy a branch of the online repository (Gitlab) to my local machine. Let's assume the branch is called "Version1" - then I want to copy this branch to a new branch called "Version2" on my local machine. Because I dont want to overwrite this branch later. The problem i got is the following: Every time I create a new branch on my local machine it is a copy of the branch that I was before.
git pull origin Version1
does not work as i want.
Would be great if someone could help.
You can create a local branch on your machine that is based off of the Version
branch.
Use the checkout
command with -b
.
First switch to the branch you want to "copy":
git checkout Version1
Next, create your own branch that is based off of Version1
:
git checkout -b Version2
Now, when you create commits while on the Version2
branch, your local copy of Version1
will remain unchanged.
Here is a good article to learn more about branching.
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