Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My team shares a "work" branch and a "stable" branch. Whenever a particular work branch is approved for further testing/release/etc, we merge it into stable. No code is ever checked directly into the stable branch.

Because of this, merge conflicts simply won't happen, and it seems silly to pull down the work branch and the stable branch, merge them, and then push the changes back. Is there a git command to ask a remote git server to commit a merge of two branches that it already knows about?

share|improve this question
You seem to be implying that pulling down both branches will involve a lot of data transfer or effort, but that isn't actually true -- the stable branch and the work branch contain the same commits. If you have a copy of the work branch then the only extra data you need to have a copy of the stable branch is the sha1 hash of its tip. And if you don't have the work branch, then how can you make any sensible edits to the repository contents? – John Bartholomew Jun 15 '12 at 19:34
up vote 1 down vote accepted

It's kinda in the nature of a DVCS that the action happens on a local machine, and gets pushed back to the main repo.

If it's that onerous, script it.


if [ ! -f ".git" ]
  echo "Not in a git repo!" >&2
  exit 1
  git checkout stable && \
  git pull origin stable && \
  git merge work && \
  git push origin stable
share|improve this answer
I assumed as much, but I figured there might just be a way. Thanks! – Brandon Yarbrough Jun 15 '12 at 19:19
@CaptainAwesomePants There may be some git extensions/add-ons for doing this, but they're usually just a bunch of bash (or python, or ruby) hacks that do almost the same thing. Gitlab has a 'merge request' feature that might be what you want, if you wanted a web interface. But generally, scripting is the easiest way to simplify your git workflow. – Jason Lewis Jun 15 '12 at 22:21

Yes - by using SSH. Just SSH into the server containing the repo. If you have permissions to write to the repository and execute git, then just cd into the repository's directory and run the git merge command.

share|improve this answer
Server-side repos are usually (and should be) 'bare' repos, so commits and merges are typically either impossible or terrible ideas. – Jason Lewis Jun 15 '12 at 22:22
Good point. I didn't think about that. – AndrewKS Jun 15 '12 at 22:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.