Hi, I ran into a problem where "git pull" was refusing to do anything, and it turns out that I hadn't set up my branch to track the remote branch I was interested in. Thanks to people on the IRC channel who pointed that out to me :) Here's a a couple of patches to clarify the documentation and to add a more helpful error message to git-pull. Federico >From 25141ff541026d5f302349a74cd6b1e7b5fa5963 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero <federico@xxxxxxx> Date: Mon, 10 Sep 2007 13:15:38 -0500 Subject: [PATCH] Better documentation for --track in git-branch and git-checkout. Make git-pull say when --track may be desirable. --- Documentation/git-branch.txt | 13 ++++++++++++- Documentation/git-checkout.txt | 5 ++++- git-pull.sh | 17 ++++++++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index 33bc31b..c5a484d 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -24,7 +24,9 @@ and option `-a` shows both. In its second form, a new branch named <branchname> will be created. It will start out with a head equal to the one given as <start-point>. If no <start-point> is given, the branch will be created with a head -equal to that of the currently checked out branch. +equal to that of the currently checked out branch. Note that this +will create the new branch, but it will not switch the working tree to +it; use "git checkout <newbranch>" to switch to the new branch. When a local branch is started off a remote branch, git can setup the branch so that gitlink:git-pull[1] will appropriately merge from that @@ -91,6 +93,15 @@ OPTIONS --no-abbrev:: Display the full sha1s in output listing rather than abbreviating them. +--track:: + Make a branch track another one, so that gitlink:git-pull[1] + will automatically merge changes from the other branch. For + example, to create a new branch and track a remote branch, you + could do "git branch --track mybranch origin/remotebranch" + +--no-track: + Make a branch not track another branch anymore. + <branchname>:: The name of the branch to create or delete. The new branch name must pass all checks defined by diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index 734928b..a0b0458 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -45,7 +45,10 @@ OPTIONS Create a new branch named <new_branch> and start it at <branch>. The new branch name must pass all checks defined by gitlink:git-check-ref-format[1]. Some of these checks - may restrict the characters allowed in a branch name. + may restrict the characters allowed in a branch name. See + also the '--track' and '--notrack' options to set up whether + the new branch should track an existing branch for use with + gitlink:git-pull[1]. --track:: When -b is given and a branch is created off a remote branch, diff --git a/git-pull.sh b/git-pull.sh index 5e96d1f..3253226 100755 --- a/git-pull.sh +++ b/git-pull.sh @@ -98,7 +98,22 @@ case "$merge_head" in curr_branch=${curr_branch#refs/heads/} echo >&2 "Warning: No merge candidate found because value of config option - \"branch.${curr_branch}.merge\" does not match any remote branch fetched." + \"branch.${curr_branch}.merge\" does not match any remote branch fetched. + This branch is not set up to track any other branches. You can set + it up now with + + git branch --track <source-branch> + + or you can do it for new branches with + + git checkout --track -b <new-branch> <source-branch> + + If you want this to be the default behavior when creating branches, + you can do + + git config branch.autosetupmerge true + + to avoid having to pass the --track option every time." echo >&2 "No changes." exit 0 ;; -- 1.5.2.4 >From 2c36c5058a028fbc603c01cc4f6abcaed0e148b4 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero <federico@xxxxxxx> Date: Mon, 10 Sep 2007 13:28:06 -0500 Subject: [PATCH] Fix whitespace Signed-off-by: Federico Mena Quintero <federico@xxxxxxx> --- Documentation/git-checkout.txt | 2 +- git-pull.sh | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index a0b0458..ec78dc8 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -47,7 +47,7 @@ OPTIONS by gitlink:git-check-ref-format[1]. Some of these checks may restrict the characters allowed in a branch name. See also the '--track' and '--notrack' options to set up whether - the new branch should track an existing branch for use with + the new branch should track an existing branch for use with gitlink:git-pull[1]. --track:: diff --git a/git-pull.sh b/git-pull.sh index 3253226..5105bd0 100755 --- a/git-pull.sh +++ b/git-pull.sh @@ -101,18 +101,18 @@ case "$merge_head" in \"branch.${curr_branch}.merge\" does not match any remote branch fetched. This branch is not set up to track any other branches. You can set it up now with - + git branch --track <source-branch> - + or you can do it for new branches with - + git checkout --track -b <new-branch> <source-branch> - + If you want this to be the default behavior when creating branches, you can do - + git config branch.autosetupmerge true - + to avoid having to pass the --track option every time." echo >&2 "No changes." exit 0 -- 1.5.2.4 - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html