diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2019-03-29 17:39:13 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-04-02 13:57:00 +0900 |
commit | ccb111b342f472d12baddbfa5b52810da1725ffd (patch) | |
tree | f681f552483efcf3253fb5fda5cc48b43b989c1b /Documentation/git-checkout.txt | |
parent | switch: add short option for --detach (diff) | |
download | tgif-ccb111b342f472d12baddbfa5b52810da1725ffd.tar.xz |
switch: implicit dwim, use --no-guess to disable it
This is already the default in git-checkout. The real change in here is
just minor cleanup. The main excuse is to explain why dwim is kept default.
Contrary to detach mode that is easy to get into and confusing to get
back out. Automatically creating a tracking branch often does not kick
in as often (you would need a branch of the same name on a remote). And
since the branch creation is reported clearly, the user should be able
to undo/delete it if it's unwanted.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/git-checkout.txt')
-rw-r--r-- | Documentation/git-checkout.txt | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index c7192bdefe..58f18a0842 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -31,22 +31,13 @@ branch. `<branch>`. + If `<branch>` is not found but there does exist a tracking branch in -exactly one remote (call it `<remote>`) with a matching name, treat as -equivalent to +exactly one remote (call it `<remote>`) with a matching name and +`--no-guess` is not specified, treat as equivalent to + ------------ $ git checkout -b <branch> --track <remote>/<branch> ------------ + -If the branch exists in multiple remotes and one of them is named by -the `checkout.defaultRemote` configuration variable, we'll use that -one for the purposes of disambiguation, even if the `<branch>` isn't -unique across all remotes. Set it to -e.g. `checkout.defaultRemote=origin` to always checkout remote -branches from there if `<branch>` is ambiguous but exists on the -'origin' remote. See also `checkout.defaultRemote` in -linkgit:git-config[1]. -+ You could omit `<branch>`, in which case the command degenerates to "check out the current branch", which is a glorified no-op with rather expensive side-effects to show only the tracking information, @@ -183,6 +174,27 @@ explicitly give a name with `-b` in such a case. Do not set up "upstream" configuration, even if the `branch.autoSetupMerge` configuration variable is true. +--guess:: +--no-guess:: + If `<branch>` is not found but there does exist a tracking + branch in exactly one remote (call it `<remote>`) with a + matching name, treat as equivalent to ++ +------------ +$ git checkout -b <branch> --track <remote>/<branch> +------------ ++ +If the branch exists in multiple remotes and one of them is named by +the `checkout.defaultRemote` configuration variable, we'll use that +one for the purposes of disambiguation, even if the `<branch>` isn't +unique across all remotes. Set it to +e.g. `checkout.defaultRemote=origin` to always checkout remote +branches from there if `<branch>` is ambiguous but exists on the +'origin' remote. See also `checkout.defaultRemote` in +linkgit:git-config[1]. ++ +Use `--no-guess` to disable this. + -l:: Create the new branch's reflog; see linkgit:git-branch[1] for details. @@ -287,10 +299,6 @@ Note that this option uses the no overlay mode by default (see also Just like linkgit:git-submodule[1], this will detach `HEAD` of the submodule. ---no-guess:: - Do not attempt to create a branch if a remote tracking branch - of the same name exists. - --overlay:: --no-overlay:: In the default overlay mode, `git checkout` never |