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

[PATCH] Make "git pull" and "git fetch" default to origin

From
Junio C Hamano <junkio@cox.net>
Date
Aug 20, 2005, 18:25 UTC
Message-ID
<7v64u0mpnp.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vvf20o4sp.fsf@assigned-by-dhcp.cox.net>

Amos Waterland sent in a patch for the pre-multi-head aware version of "git pull" to do this, but the code changed quite a bit since then. If there is no argument given to pull from, and if "origin" makes sense, default to fetch/pull from "origin" instead of barfing.

[jc: besides, the patch by Amos broke the non-default case where explicit refspecs are specified, and did not make sure we know what "origin" means before defaulting to it.]

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 git-fetch-script |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
6d8fcdbf772f4fc4ec7ae67630b52bc8a07d7b6d
diff --git a/git-fetch-script b/git-fetch-script
--- a/git-fetch-script
+++ b/git-fetch-script
@@ -8,7 +8,10 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x4
 append=
 case "$#" in
 0)
-	die "Where do you want to fetch from?" ;;
+	test -f "$GIT_DIR/branches/origin" ||
+		test -f "$GIT_DIR/remotes/origin" ||
+			die "Where do you want to fetch from?"
+	set origin ;;
 *)
 	case "$1" in
 	-a|--a|--ap|--app|--appe|--appen|--append)
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 7 in “Updated multi-head downloads and $GIT_DIR/remotes/ support”
  1. Junio C HamanoAug 20, 2005
  2. Start adding the $GIT_DIR/remotes/ support.Junio C Hamano, Aug 20, 2005
  3. Multi-head fetch.Junio C Hamano, Aug 20, 2005
  4. Retire git-parse-remote.Junio C Hamano, Aug 20, 2005
  5. Infamous 'octopus merge'Junio C Hamano, Aug 20, 2005
  6. Make "git pull" and "git fetch" default to originJunio C Hamano, Aug 20, 2005
  7. Use .git/remote/origin, not .git/branches/origin.Junio C Hamano, Aug 20, 2005

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.