Reputation: 1153
So in our repository we currently have the following branches:
Master
Dev1
I would like to create my own local and remote branch called Dev2 and would like it to initially pull from the remote Dev1 instead of Master (since Dev1 is the most up-to-date and hasn't merged into the Master branch yet). When I then push to my remote branch I want to be pushin to Dev2 which should be a completely detached and independent branch from Dev1.
How could I do this? I am new to using Git, if you couldn't tell :)
Upvotes: 0
Views: 43
Reputation: 26
You need to first fetch the remote branch on your local system by
git fetch remote_name remote_branch_name
in your case the remote_branch_name would be Dev1
Now you need to create a new branch from Dev1, which you can do like this
git checkout -b new_branch_name remote_name/remote_branch_name
new_branch_name for you would be Dev2
Now whenever you'll push, you can do
git push remote_name new_branch_name
Upvotes: 1
Reputation: 38136
You can use below commands to meet your requirement:
git checkout origin/Dev1
git checkout --orphan Dev2
# make some changes and commit them if have
git push -u origin Dev2
Upvotes: 0