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

Re: specifying "fast-forward" only in git-pull

From
Junio C Hamano <junkio@cox.net>
Date
Mar 28, 2007, 21:26 UTC
Message-ID
<7vbqidf4a8.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<e1dab3980703281412m78c2481bj9b9f7ec885dbbe4f@mail.gmail.com>
"David Tweed" <david.tweed@gmail.com> writes:
Show 14 quoted lines
> Hi, I'm looking through the documentation on git-pull and
> I see that I can specify a particular (sequence of) merge
> strategies, but I can't see a way to say "only do a fast
> forward, stopping if a fast forward doesn't apply".
> (Fast-forward doesn't appear to be a named strategy,
> which is why I can't use it with -s). Is there a way to
> do this?
>
> Rationale: I have a repository on several machines that
> are synchronised via usb-stick. 99.9% of the time a fast
> forward is all that is needed, and for scripting the
> synchronisation I'd like to restrict it so that only
> fast-forwards can happen automatically and everything
> else I have to do by invoking git myself.

Presumably you are scripting around "git pull" and wondering if there is a way to let you say "git pull -s ffonly $stick".

Why don't you script around "git fetch" instead?
	#!/bin/sh
 	stick=$1
       
	git fetch "$stick"
        not_in_stick=$(git rev-list FETCH_HEAD..HEAD)
        if test -z "$not_in_stick"
        then
        	: stick fast forwards
                git merge FETCH_HEAD
	else
        	echo >&2 "Our HEAD has things the stick does not."
		exit 1
	fi
Previous: David TweedNext: Shawn O. Pearce
Message 2 of 3 in “specifying "fast-forward" only in git-pull”
  1. David TweedMar 28, 2007
  2. Junio C HamanoMar 28, 2007
  3. Shawn O. PearceMar 28, 2007

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.