Code

Explicitly add the default "git pull" behaviour to .git/config on clone
authorAndy Parkins <andyparkins@gmail.com>
Wed, 6 Dec 2006 12:07:23 +0000 (12:07 +0000)
committerJunio C Hamano <junkio@cox.net>
Wed, 6 Dec 2006 19:24:04 +0000 (11:24 -0800)
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>
git-clone.sh

index 0ace989fdee82bc1c9bd19fe42d58872f22c2d9c..1f5d07a057ed04dd9ffc7eb705d0c752d250bf72 100755 (executable)
@@ -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