Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging to a branch in git without switching to it

I have an application running in a git repository on a branch (say dev). The application modifies the content in some the repository and commits them. I now have to merge these changes into another branch (say master) but the snag is that I don't want to git checkout master before doing this. Is there some way to say "merge current branch into master"?

like image 919
Noufal Ibrahim Avatar asked Jul 01 '11 12:07

Noufal Ibrahim


People also ask

How do I merge to a specific branch?

To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch. This example merges the jeff/feature1 branch into the main branch.

How do I merge a branch without committing?

Thus, if you want to ensure your branch is not changed or updated by the merge command, use --no-ff with --no-commit.

Can I merge branch without pull request?

It looks like GitHub only allows merging of branches by making a pull request and then merging. Is there a way to merge mobile into master in a single step without cloning locally? There's no way without using a pull request.


1 Answers

The "master" in your case appears to be "fast-forwardable". You could "push" the branch to master.

cd /path_to_dir_with_no_branch_switch/ git push . appbranch:master 
like image 189
Anil Avatar answered Oct 08 '22 18:10

Anil