Skip to content

Commit

Permalink
Explicitly add the default "git pull" behaviour to .git/config on clone
Browse files Browse the repository at this point in the history
Without any specification in the .git/config file, git-pull will execute
"git-pull origin"; which in turn defaults to pull from the first "pull"
definition for the remote, "origin".

This is a difficult set of defaults to track for a new user, and it's
difficult to see what tells git to do this (especially when it is
actually hard-coded behaviour).  To ameliorate this slightly, this patch
explicitly specifies the default behaviour during a clone using the
"branch" section of the config.

For example, a clone of a typical repository would create a .git/config
containing:
  [remote "origin"]
  url = proto://host/repo.git
  fetch = refs/heads/master:refs/remotes/origin/master
  [branch "master"]
  remote = origin
  merge = refs/heads/master

The [branch "master"] section is such that there is no change to the
functionality of git-pull, but that functionality is now explicitly
documented.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
  • Loading branch information
Andy Parkins authored and Junio C Hamano committed Dec 6, 2006
1 parent de51faf commit 955289b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion git-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ then
rm -f "refs/remotes/$origin/HEAD"
git-symbolic-ref "refs/remotes/$origin/HEAD" \
"refs/remotes/$origin/$head_points_at"
esac
esac &&
git-repo-config branch."$head_points_at".remote "$origin" &&
git-repo-config branch."$head_points_at".merge "refs/heads/$head_points_at"
esac

case "$no_checkout" in
Expand Down

0 comments on commit 955289b

Please sign in to comment.