Search code examples
gitbranchremote-branch

Swith remote branches in git


Say I have two remote git branches, A and B.

I want branch A to contain the contents of branch B and later remove B, so that only branch A remains with B's original contents.

Unfortunately, the remote repository won't allow my to simply delete the branch A, so I'm stuck with somehow copying over B into A.

Is this possible using only git commands?


Solution

  • yes, this is git's core feature. have a look at https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging

    $ git checkout A
    $ git merge B
    

    you then could delete B following this answer: How do I delete a Git branch both locally and remotely?