Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge local branch into remote branch other than master?

Tags:

git

github

so I have a local branch A that doesn't exist yet in remote repo. And I have remote branch B in remote repo. How do I merge my local changes into the remote branch?

refer me to some links if you can.

like image 453
Square-root Avatar asked Oct 20 '16 04:10

Square-root


People also ask

How do I merge a local branch to another remote branch?

The idea here, is to merge "one of your local branch" (here anotherLocalBranch ) to a remote branch ( origin/aBranch ). For that, you create first " myBranch " as representing that remote branch: that is the git checkout -b myBranch origin/aBranch part. And then you can merge anotherLocalBranch to it (to myBranch ).

How do I merge a branch with another master?

First we run git checkout master to change the active branch back to the master branch. Then we run the command git merge new-branch to merge the new feature into the master branch. Note: git merge merges the specified branch into the currently active branch. So we need to be on the branch that we are merging into.

How do I merge locally in git?

To do a merge (locally), git checkout the branch you want to merge INTO. Then type git merge <branch> where <branch> is the branch you want to merge FROM. Because the history of master and the history of make_function share common ancestors and don't have any divergence descendents, we get a "fast-forward" merge.


1 Answers

If branch B is at local, You can merge A to B locally and push B to remote:

git checkout B
git merge A
git push origin B

If you don't have B at local, you can push A to remote and pull request to merge A to B and click merge button on github.

or, fetch B branch to local and merge A to B , then push B to remote, like this:

git checkout master
git fetch orign B:B       (fetch B to local)
git checkout B            (checkout to branch B)
git merge A               (merge A to B)
git push origin B         (push merged branch B to remote)
like image 67
Frank Avatar answered Nov 15 '22 13:11

Frank