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

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

From
knittl <knittl89@googlemail.com>
Date
Jul 18, 2011, 16:24 UTC
Message-ID
<CACx-yZ3_nZT61GXqE4uF5JRVekrqFKT4++spEKpL3vPdM8Nh8Q@mail.gmail.com>
In-Reply-To
<CAF_dkJAx4mK26HcarMtRosy=MU8DgKx9aHWXXbTMK9kG=1LZWQ@mail.gmail.com>
On Mon, Jul 18, 2011 at 6:13 PM, Patrick Doyle <wpdster@gmail.com> wrote:
Show 23 quoted lines
> On Mon, Jul 18, 2011 at 12:08 PM, knittl <knittl89@googlemail.com> wrote:
>> On Mon, Jul 18, 2011 at 4:18 PM, Patrick Doyle <wpdster@gmail.com> wrote:
>>> […]
>>>
>>> $ git push
>>> […]
>>> 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.
>>>
>>
>> another way to avoid pushing the master branch is to explicitely name
>> the branch to push (wpd):
>>
>>    $ git push origin wpd
>>
> Thanks... I thought of that, but being basically lazy and not wanting
> to have to type all of those extra characters every time I did a "git
> push", I wanted to figure out a better way.
I can understand your laziness ;)
Show 9 quoted lines
> Seth Milliken posted a great explanation and alternative solution in a
> comment to a blog post I found at
> http://ken-blog.krugler.org/2010/02/25/git-failed-to-push-some-refs-the-multiple-branch-variant/.
>  He suggested doing:
>
> $ git config remote.origin.push HEAD
>
> So that "git push" would default to only pushing the current branch.
> I like that approach to my underlying problem as well.
I prefer to use
    $ git config --global push.default current

which tells git to push the current branch to a branch of the same name (for every repository). Another possible (and useful) value is "upstream"/"tracking": push the current branch to it's upstream. Have a look at the git config manpage for more options.

> But I stand in awe of Hanne's solution (#2) for it's brevity, the fact
> that it does _exactly_ what I was asking about, and that the
> capability is already baked into git.

Yup, pushing into the current repository to fast-forward branches without checkout is quite neat indeed :)

Daniel
-- 
typed with http://neo-layout.org
myFtPhp -- visit http://myftphp.sf.net -- v. 0.4.7 released!
Previous: Patrick Doyle
Message 6 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.