I have created branch this way:
git branch MyBranch origin/test
test
was branch parallel to master. Now test is merged into master
How can i change the origin of MyBranch
so it points to master
There is no "origin" of a branch. A "branch" is just a label pointing at particular commit.
If you've made no commits to MyBranch, then you can delete and recreate it.
git branch -d MyBranch
git branch MyBranch master
If you have done work on MyBranch, then things are a little more complicated. Your situation is like this...
- A - B - C - D [master]
\
E - F [origin/test]
\
G - H [MyBranch]
MyBranch
has commits G and H on top of origin/test
. If you want to move MyBranch
on top of master
then you need to preserve the work in G and H. This can be done with a rebase.
git rebase --onto master origin/test MyBranch
This says to take the changes which are in MyBranch
but not in origin/test
(which is G and H) and put them on top of master
. You get...
G1 - H1 [MyBranch]
/
- A - B - C - D [master]
\
E - F [origin/test]
\
G - H
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