git/list[1] front-page[2] threads[3] people[4] search[5] about
 

How to do a fast-forward merge without a checkout?

From
PDPatrick Doyle <wpdster@gmail.com>
Date
Jul 18, 2011, 14:18 UTC
Message-ID
<CAF_dkJCvtVqoDmRXMy23ZnZL6iUAVX0nNA9Ev6e4zvBp9mfTpg@mail.gmail.com>
Huh?  What does he mean by that?
I have the following in my .git/config file:
[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = somehost:path/to/repo
[branch "master"]
	remote = origin
	merge = refs/heads/master
[branch "wpd"]
	remote = origin
	merge = refs/heads/wpd

I have been working on my "wpd" branch on a couple of different machines and have been happily committing, pushing, and pulling from my "origin" host. Recently, however, somebody committed a change on the "master" branch. Now, when I do a "git push", I get the following

$ git push
Counting objects: 11, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 715 bytes, done.
Total 6 (delta 4), reused 0 (delta 0)
To somehost:path/to/repo
   e1004df..bad8767  wpd -> wpd
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'somehost:path/to/repo'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

The last time I encountered this, I did a "get checkout master; git merge origin/master; git checkout wpd; git push" and that worked. I happen to know that master is a direct descendent of origin/master and that, if I do this again, I will (once again) do a fast-forward merge to bring master up to origin/master.

This may have been fixed in a more recent git (I'm using git 1.7.2.5 on a Debian 6 box and 1.7.4.1 on an RHEL 5 box).

There has got to be an easier way to fix this than checking out the master branch, performing the fast-forward merge, and then switching back to my working branch.

One way would be if there were some way to do a fast-forward merge on a branch without actually checking out that branch. Hence my question.

Another way would be to remove the "master" branch from my config file.
Or perhaps I set up something wrong.
--wpd
Next: Johannes Sixt
Message 1 of 6 in “How to do a fast-forward merge without a checkout?”
  1. Patrick DoyleJul 18, 2011
  2. Johannes SixtJul 18, 2011
  3. Patrick DoyleJul 18, 2011
  4. knittlJul 18, 2011
  5. Patrick DoyleJul 18, 2011
  6. knittlJul 18, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.