Josef Weidendorfer <Josef.Weidendorfer@xxxxxx> writes: > Example to hack on git's next branch: > > git-clone --use-separate-remote http://www.kernel.org/pub/scm/git/git.git > cd git > git-checkout origin/next > <hack on next> > git pull (to merge patches from remote 'next') > > The checkout creates local branch 'next' to checkout read-only > remote branch 'remotes/origin/next'. Additionally, it sets up > 'remotes/origin/next' from remote repository 'origin' as > default merge source for the new development branch. I am disturbed by an inconsistency here. > + if git-show-ref --verify --quiet -- "refs/heads/$newbranch" > + then > + echo "Proposed new branch '$newbranch' to checkout... > + echo "To checkout, specify a new branch name with -b" > + exit 1 > + fi This logic is guarding against already having a local branch that is called 'next', and that is why the "Proposed new branch" message needs to be there. One explanation of why 'next' exists in the local branch namespace in the first place is probably there are other remote branches than origin that have 'next' and the user previously checked it out. Or perhaps the user has already done this "checkout origin/next" once already. I wonder if it is more consistent and easy to use to just make this: git checkout origin/next a synonym to: git checkout -b origin/next remotes/origin/next when remotes/origin/next exists and heads/origin/next does not. Then "git checkout origin/next" would always mean "I want to switch to the branch I use to hack on the branch 'next' Junio has". Do it once and you will get exactly my tip, hack on it, switch out of it and then do it again and you won't lose your previous work but just switch to that branch. That is, something like this... --- diff --git a/git-checkout.sh b/git-checkout.sh index 119bca1..f6486c6 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -4,6 +4,16 @@ USAGE='[-f] [-b <new_branch>] [-m] [<bra SUBDIRECTORY_OK=Sometimes . git-sh-setup +# Automatic forking of local branch based on remote +if test $# = 1 && + git show-ref --verify --quiet -- "refs/remotes/$1" && + ! git show-ref --verify --quiet -- "refs/heads/$1" +then + set x -b "$1" "remotes/$1" + echo >&2 "* Forking local branch $1 off of remotes/$1..." + shift +fi + old_name=HEAD old=$(git-rev-parse --verify $old_name 2>/dev/null) new= - 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