Commit graph

178 commits

Author SHA1 Message Date
Andreas Heiduk 39a36827ac doc: fix ASCII art tab spacing
Followup to 5dd05ebf ("doc: fix merge-base ASCII art tab spacing", 2016-10-21)

Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-10-23 12:23:09 +09:00
Ævar Arnfjörð Bjarmason 8d7b558bae checkout & worktree: introduce checkout.defaultRemote
Introduce a checkout.defaultRemote setting which can be used to
designate a remote to prefer (via checkout.defaultRemote=origin) when
running e.g. "git checkout master" to mean origin/master, even though
there's other remotes that have the "master" branch.

I want this because it's very handy to use this workflow to checkout a
repository and create a topic branch, then get back to a "master" as
retrieved from upstream:

    (
        cd /tmp &&
        rm -rf tbdiff &&
        git clone git@github.com:trast/tbdiff.git &&
        cd tbdiff &&
        git branch -m topic &&
        git checkout master
    )

That will output:

    Branch 'master' set up to track remote branch 'master' from 'origin'.
    Switched to a new branch 'master'

But as soon as a new remote is added (e.g. just to inspect something
from someone else) the DWIMery goes away:

    (
        cd /tmp &&
        rm -rf tbdiff &&
        git clone git@github.com:trast/tbdiff.git &&
        cd tbdiff &&
        git branch -m topic &&
        git remote add avar git@github.com:avar/tbdiff.git &&
        git fetch avar &&
        git checkout master
    )

Will output (without the advice output added earlier in this series):

    error: pathspec 'master' did not match any file(s) known to git.

The new checkout.defaultRemote config allows me to say that whenever
that ambiguity comes up I'd like to prefer "origin", and it'll still
work as though the only remote I had was "origin".

Also adjust the advice.checkoutAmbiguousRemoteBranchName message to
mention this new config setting to the user, the full output on my
git.git is now (the last paragraph is new):

    $ ./git --exec-path=$PWD checkout master
    error: pathspec 'master' did not match any file(s) known to git.
    hint: 'master' matched more than one remote tracking branch.
    hint: We found 26 remotes with a reference that matched. So we fell back
    hint: on trying to resolve the argument as a path, but failed there too!
    hint:
    hint: If you meant to check out a remote tracking branch on, e.g. 'origin',
    hint: you can do so by fully qualifying the name with the --track option:
    hint:
    hint:     git checkout --track origin/<name>
    hint:
    hint: If you'd like to always have checkouts of an ambiguous <name> prefer
    hint: one remote, e.g. the 'origin' remote, consider setting
    hint: checkout.defaultRemote=origin in your config.

I considered splitting this into checkout.defaultRemote and
worktree.defaultRemote, but it's probably less confusing to break our
own rules that anything shared between config should live in core.*
than have two config settings, and I couldn't come up with a short
name under core.* that made sense (core.defaultRemoteForCheckout?).

See also 70c9ac2f19 ("DWIM "git checkout frotz" to "git checkout -b
frotz origin/frotz"", 2009-10-18) which introduced this DWIM feature
to begin with, and 4e85333197 ("worktree: make add <path> <branch>
dwim", 2017-11-26) which added it to git-worktree.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-06-11 09:41:02 -07:00
Junio C Hamano 706566524e Merge branch 'ks/doc-checkout-previous'
@{-N} in "git checkout @{-N}" may refer to a detached HEAD state,
but the documentation was not clear about it, which has been fixed.

* ks/doc-checkout-previous:
  Doc/checkout: checking out using @{-N} can lead to detached state
2017-12-13 13:28:57 -08:00
Junio C Hamano 0b75572a1b Merge branch 'sb/submodule-recursive-checkout-detach-head'
"git checkout --recursive" may overwrite and rewind the history of
the branch that happens to be checked out in submodule
repositories, which might not be desirable.  Detach the HEAD but
still allow the recursive checkout to succeed in such a case.

* sb/submodule-recursive-checkout-detach-head:
  Documentation/checkout: clarify submodule HEADs to be detached
  recursive submodules: detach HEAD from new state
2017-12-06 09:23:35 -08:00
Kaartic Sivaraam 75ce149575 Doc/checkout: checking out using @{-N} can lead to detached state
@{-N} is a syntax for the N-th last "checkout" and not the N-th
last "branch". Therefore, in some cases using `git checkout @{-$N}`
DOES lead to a "detached HEAD" state. This can also be ensured by
the commit message of 75d6e552a (Documentation: @{-N} can refer to
a commit, 2014-01-19) which clearly specifies how @{-N} can be used
to refer not only to a branch but also to a commit.

Correct the misleading sentence which states that @{-N} doesn't
detach HEAD.

Signed-off-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-11-28 11:33:12 +09:00
Junio C Hamano 4339c9f2df Merge branch 'jc/doc-checkout'
Doc update.

* jc/doc-checkout:
  checkout doc: clarify command line args for "checkout paths" mode
2017-10-17 13:29:19 +09:00
Junio C Hamano b59698aef3 checkout doc: clarify command line args for "checkout paths" mode
There are "git checkout [-p][<tree-ish>][--][<paths>...]" in the
SYNOPSIS section, and "git checkout [-p][<tree-ish>][--]<paths>..."
as the header for the section that explains the "check out paths
from index/tree-ish" mode.  It is unclear if we require at least one
path, or it is entirely optional.

Actually, both are wrong.  Without the "-p(atch)" option, you must
have <pathspec> (otherwise, with a commit that is a <tree-ish>, you
would be checking out that commit to build a new history on top of
it).  With it, it is already clear that you are checking out paths,
it is optional.  In other words, you cannot omit both.

The source of the confusion is that -p(atch) is described as if it
is just another "optional" part and its description is lumped
together with the non patch mode, even though the actual end user
experience is vastly different.

Let's split the entry into two, and describe the regular mode and
the patch mode separately.  This allows us to make it clear that the
regular mode MUST be given at least one pathspec, that the patch
mode can be invoked with either '-p' or '--patch' but one of these
must be given, and that the pathspec is entirely optional in the
patch mode.

Also, revamp the explanation of "checkout paths" by removing
extraneous description at the beginning, that says "checking out
paths is not checking out a branch".  Explaining what it is for and
when the user wants to use it upfront is the most direct way to help
the readers.

Noticed-by: Robert P J Day
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-10-11 14:55:36 +09:00
Evan Zacks be94568bc7 doc: fix minor typos (extra/duplicated words)
Following are several fixes for duplicated words ("of of") and one
case where an extra article ("a") slipped in.

Signed-off-by: Evan Zacks <zackse@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-09-14 15:09:02 +09:00
Stefan Beller 57f22bf997 Documentation/checkout: clarify submodule HEADs to be detached
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-07-28 15:26:02 -07:00
Stefan Beller 1fc458d958 builtin/checkout: add --recurse-submodules switch
This exposes a flag to recurse into submodules
in builtin/checkout making use of the code implemented
in prior patches.

A new failure mode is introduced in the submodule
update library, as the directory/submodule conflict
is not solved in prior patches.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-16 14:07:16 -07:00
Nguyễn Thái Ngọc Duy 19e5656345 checkout.txt: document a common case that ignores ambiguation rules
Normally we err on the safe side: if something can be seen as both an
SHA1 and a pathspec, we stop and scream. In checkout, there is one
exception added in 859fdab (git-checkout: improve error messages, detect
ambiguities. - 2008-07-23), to allow the common case "git checkout
branch". Let's document this exception.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-09-21 08:44:41 -07:00
Matthieu Moy 23f8239bbe doc: typeset short command-line options as literal
It was common in our documentation to surround short option names with
forward quotes, which renders as italic in HTML. Instead, use backquotes
which renders as monospace. This is one more step toward conformance to
Documentation/CodingGuidelines.

This was obtained with:

  perl -pi -e "s/'(-[a-z])'/\`\$1\`/g" *.txt

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-06-28 08:20:52 -07:00
Edmundo Carmona Antoranz 870ebdb9c4 checkout: add --progress option
Under normal circumstances, and like other git commands,
git checkout will write progress info to stderr if
attached to a terminal. This option allows progress
to be forced even if not using a terminal. Also,
progress can be skipped if using option --no-progress.

Signed-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-11-01 14:08:17 -08:00
Junio C Hamano c0b901eaf7 Merge branch 'se/doc-checkout-ours-theirs'
A "rebase" replays changes of the local branch on top of something
else, as such they are placed in stage #3 and referred to as
"theirs", while the changes in the new base, typically a foreign
work, are placed in stage #2 and referred to as "ours".  Clarify
the "checkout --ours/--theirs".

* se/doc-checkout-ours-theirs:
  checkout: document subtlety around --ours/--theirs
2015-08-03 11:01:25 -07:00
Junio C Hamano 799767cc98 Merge branch 'es/worktree-add'
Update to the "linked checkout" in 2.5.0-rc1.

Instead of "checkout --to" that does not do what "checkout"
normally does, move the functionality to "git worktree add".

* es/worktree-add: (24 commits)
  Revert "checkout: retire --ignore-other-worktrees in favor of --force"
  checkout: retire --ignore-other-worktrees in favor of --force
  worktree: add: auto-vivify new branch when <branch> is omitted
  worktree: add: make -b/-B default to HEAD when <branch> is omitted
  worktree: extract basename computation to new function
  checkout: require worktree unconditionally
  checkout: retire --to option
  tests: worktree: retrofit "checkout --to" tests for "worktree add"
  worktree: add -b/-B options
  worktree: add --detach option
  worktree: add --force option
  worktree: introduce "add" command
  checkout: drop 'checkout_opts' dependency from prepare_linked_checkout
  checkout: make --to unconditionally verbose
  checkout: prepare_linked_checkout: drop now-unused 'new' argument
  checkout: relocate --to's "no branch specified" check
  checkout: fix bug with --to and relative HEAD
  Documentation/git-worktree: add EXAMPLES section
  Documentation/git-worktree: add high-level 'lock' overview
  Documentation/git-worktree: split technical info from general description
  ...
2015-07-13 14:02:19 -07:00
Junio C Hamano c925fe2368 Revert "checkout: retire --ignore-other-worktrees in favor of --force"
This reverts commit 0d1a151783.

When trying to switch to a different branch, that happens to be
checked out in another working tree, the user shouldn't have to
give up the other safety measures (like protecting the local changes
that overlap the difference between the branches) while defeating
the "no two checkouts of the same branch" safety.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-12 09:38:21 -07:00
Simon A. Eugster f30301657b checkout: document subtlety around --ours/--theirs
During a 'rebase' (hence 'pull --rebase'), --ours/--theirs may
appear to be swapped to those who are not aware of the fact that
they are temporarily playing the role of the keeper of the more
authoritative history.

Add a note to clarify.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Simon A. Eugster <simon.eugster@eps.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-12 09:28:24 -07:00
Junio C Hamano e12fc40a15 Merge branch 'tb/checkout-doc'
Doc update.

* tb/checkout-doc:
  git-checkout.txt: document "git checkout <pathspec>" better
2015-07-10 14:17:54 -07:00
Eric Sunshine 0d1a151783 checkout: retire --ignore-other-worktrees in favor of --force
As a safeguard, checking out a branch already checked out by a different
worktree is disallowed. This behavior can be overridden with
--ignore-other-worktrees, however, this option is neither obvious nor
particularly discoverable. As a common safeguard override, --force is
more likely to come to mind. Therefore, overload it to also suppress the
check for a branch already checked out elsewhere.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-07 14:34:46 -07:00
Eric Sunshine b979d95027 checkout: retire --to option
Now that "git worktree add" has achieved user-facing feature-parity with
"git checkout --to", retire the latter.

Move the actual linked worktree creation functionality,
prepare_linked_checkout() and its helpers, verbatim from checkout.c to
worktree.c.

This effectively reverts changes to checkout.c by 529fef2 (checkout:
support checking out into a new working directory, 2014-11-30) with the
exception of merge_working_tree() and switch_branches() which still
require specialized knowledge that a the checkout is occurring in a
newly-created linked worktree (signaled to them by the private
GIT_CHECKOUT_NEW_WORKTREE environment variable).

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-06 11:07:47 -07:00
Eric Sunshine 93a36493e2 Documentation: move linked worktree description from checkout to worktree
Now that the git-worktree command exists, its documentation page is the
natural place for the linked worktree description to reside. Relocate
the "MULTIPLE WORKING TREES" description verbatim from git-checkout.txt
to git-worktree.txt.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-06 11:07:43 -07:00
Eric Sunshine 5c31464874 Documentation/git-checkout: fix incorrect worktree prune command
This was missed when "git prune --worktrees" became "git worktree prune".

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-06 11:07:42 -07:00
Torsten Bögershausen c4ac525c84 git-checkout.txt: document "git checkout <pathspec>" better
git checkout <pathspec> can be used to reset changes in the working tree.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-06-17 13:33:06 -07:00
Junio C Hamano 68a2e6a2c8 Merge branch 'nd/multiple-work-trees'
A replacement for contrib/workdir/git-new-workdir that does not
rely on symbolic links and make sharing of objects and refs safer
by making the borrowee and borrowers aware of each other.

* nd/multiple-work-trees: (41 commits)
  prune --worktrees: fix expire vs worktree existence condition
  t1501: fix test with split index
  t2026: fix broken &&-chain
  t2026 needs procondition SANITY
  git-checkout.txt: a note about multiple checkout support for submodules
  checkout: add --ignore-other-wortrees
  checkout: pass whole struct to parse_branchname_arg instead of individual flags
  git-common-dir: make "modules/" per-working-directory directory
  checkout: do not fail if target is an empty directory
  t2025: add a test to make sure grafts is working from a linked checkout
  checkout: don't require a work tree when checking out into a new one
  git_path(): keep "info/sparse-checkout" per work-tree
  count-objects: report unused files in $GIT_DIR/worktrees/...
  gc: support prune --worktrees
  gc: factor out gc.pruneexpire parsing code
  gc: style change -- no SP before closing parenthesis
  checkout: clean up half-prepared directories in --to mode
  checkout: reject if the branch is already checked out elsewhere
  prune: strategies for linked checkouts
  checkout: support checking out into a new working directory
  ...
2015-05-11 14:23:39 -07:00
Nguyễn Thái Ngọc Duy da0005b885 *config.txt: stick to camelCase naming convention
This should improve readability. Compare "thislongname" and
"thisLongName". The following keys are left in unchanged. We can
decide what to do with them later.

 - am.keepcr
 - core.autocrlf .safecrlf .trustctime
 - diff.dirstat .noprefix
 - gitcvs.usecrlfattr
 - gui.blamehistoryctx .trustmtime
 - pull.twohead
 - receive.autogc
 - sendemail.signedoffbycc .smtpsslcertpath .suppresscc

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-03-13 22:13:46 -07:00
Nguyễn Thái Ngọc Duy a83a66aca2 git-checkout.txt: a note about multiple checkout support for submodules
The goal seems to be using multiple checkouts to reduce disk space.
But we have not reached an agreement how things should be. There are a
couple options.

 - You may want to keep $SUB repos elsewhere (perhaps in a central
   place) outside $SUPER. This is also true for nested submodules
   where a superproject may be a submodule of another superproject.

 - You may want to keep all $SUB repos in $SUPER/modules (or some
   other place in $SUPER)

 - We could even push it further and merge all $SUB repos into $SUPER
   instead of storing them separately. But that would at least require
   ref namespace enabled.

On top of that, git-submodule.sh expects $GIT_DIR/config to be
per-worktree, at least for the submodule.* part. Here I think we have
two options, either update config.c to also read
$GIT_DIR/config.worktree (which is per worktree) in addition to
$GIT_DIR/config (shared) and store worktree-specific vars in the new
place, or update git-submodule.sh to read/write submodule.* directly
from $GIT_DIR/config.submodule (per worktree).

These take time to address properly. Meanwhile, make a note to the
user that they should not use multiple worktrees in submodule context.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-07 10:25:20 -08:00
Nguyễn Thái Ngọc Duy 1d0fa898ea checkout: add --ignore-other-wortrees
Noticed-by: Mark Levedahl <mlevedahl@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-01-07 10:23:08 -08:00
Nguyễn Thái Ngọc Duy e3df33bb1b gc: support prune --worktrees
Helped-by: Marc Branchaud <marcnarc@xiplink.com>
Signed-off-by: Marc Branchaud <marcnarc@xiplink.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-12-01 11:00:18 -08:00
Nguyễn Thái Ngọc Duy 23af91d102 prune: strategies for linked checkouts
(alias R=$GIT_COMMON_DIR/worktrees/<id>)

 - linked checkouts are supposed to keep its location in $R/gitdir up
   to date. The use case is auto fixup after a manual checkout move.

 - linked checkouts are supposed to update mtime of $R/gitdir. If
   $R/gitdir's mtime is older than a limit, and it points to nowhere,
   worktrees/<id> is to be pruned.

 - If $R/locked exists, worktrees/<id> is not supposed to be pruned. If
   $R/locked exists and $R/gitdir's mtime is older than a really long
   limit, warn about old unused repo.

 - "git checkout --to" is supposed to make a hard link named $R/link
   pointing to the .git file on supported file systems to help detect
   the user manually deleting the checkout. If $R/link exists and its
   link count is greated than 1, the repo is kept.

Helped-by: Marc Branchaud <marcnarc@xiplink.com>
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Marc Branchaud <marcnarc@xiplink.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-12-01 11:00:17 -08:00
Nguyễn Thái Ngọc Duy 529fef20cf checkout: support checking out into a new working directory
"git checkout --to" sets up a new working directory with a .git file
pointing to $GIT_DIR/worktrees/<id>. It then executes "git checkout"
again on the new worktree with the same arguments except "--to" is
taken out. The second checkout execution, which is not contaminated
with any info from the current repository, will actually check out and
everything that normal "git checkout" does.

Helped-by: Marc Branchaud <marcnarc@xiplink.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-12-01 11:00:16 -08:00
Thomas Rast 75d6e552a8 Documentation: @{-N} can refer to a commit
The @{-N} syntax always referred to the N-th last thing checked out,
which can be either a branch or a commit (for detached HEAD cases).
However, the documentation only mentioned branches.

Edit in a "/commit" in the appropriate places.

Reported-by: Kevin <ikke@ikke.info>
Signed-off-by: Thomas Rast <tr@thomasrast.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-21 13:50:00 -08:00
Junio C Hamano 26776c9737 checkout: update synopsys and documentation on detaching HEAD
In the synopsis, the second form to detach HEAD at the named commit
labelled the argument as '<commit>'.  While this is technically more
correct, because the feature to detach is not limited to the tip of
a named branch, it was found confusing and did not express the fact
that you have to give `--detach` if you are naming the commit you
want to detach HEAD at with a branch name.

Separate this case into two syntactical forms, mimicking the way how
the DESCRIPTION section shows this usage.  Also update the text that
explains the syntax to name the commit to detach HEAD at to clarify.

Suggested-by: Benjamin Bergman <ben@benbergman.ca>
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-09-11 12:32:01 -07:00
Junio C Hamano 77eb44b8ed Merge branch 'jh/checkout-auto-tracking'
Update "git checkout foo" that DWIMs the intended "upstream" and
turns it into "git checkout -t -b foo remotes/origin/foo" to
correctly take existing remote definitions into account.

The remote "origin" may be what uniquely map its own branch to
remotes/some/where/foo but that some/where may not be "origin".

* jh/checkout-auto-tracking:
  glossary: Update and rephrase the definition of a remote-tracking branch
  branch.c: Validate tracking branches with refspecs instead of refs/remotes/*
  t9114.2: Don't use --track option against "svn-remote"-tracking branches
  t7201.24: Add refspec to keep --track working
  t3200.39: tracking setup should fail if there is no matching refspec.
  checkout: Use remote refspecs when DWIMming tracking branches
  t2024: Show failure to use refspec when DWIMming remote branch names
  t2024: Add tests verifying current DWIM behavior of 'git checkout <branch>'
2013-05-29 14:23:10 -07:00
Johan Herland fa83a33b22 checkout: Use remote refspecs when DWIMming tracking branches
The DWIM mode of checkout allows you to run "git checkout foo" when there
is no existing local ref or path called "foo", and there is exactly _one_
remote with a remote-tracking branch called "foo". Git will automatically
create a new local branch called "foo" using the remote-tracking "foo" as
its starting point and configured upstream.

For example, consider the following unconventional (but perfectly valid)
remote setup:

	[remote "origin"]
		fetch = refs/heads/*:refs/remotes/origin/*
	[remote "frotz"]
		fetch = refs/heads/*:refs/remotes/frotz/nitfol/*

Case 1: Assume both "origin" and "frotz" have remote-tracking branches called
"foo", at "refs/remotes/origin/foo" and "refs/remotes/frotz/nitfol/foo"
respectively. In this case "git checkout foo" should fail, because there is
more than one remote with a "foo" branch.

Case 2: Assume only "frotz" have a remote-tracking branch called "foo". In
this case "git checkout foo" should succeed, and create a local branch "foo"
from "refs/remotes/frotz/nitfol/foo", using remote branch "foo" from "frotz"
as its upstream.

The current code hardcodes the assumption that all remote-tracking branches
must match the "refs/remotes/$remote/*" pattern (which is true for remotes
with "conventional" refspecs, but not true for the "frotz" remote above).
When running "git checkout foo", the current code looks for exactly one ref
matching "refs/remotes/*/foo", hence in the above example, it fails to find
"refs/remotes/frotz/nitfol/foo", which causes it to fail both case #1 and #2.

The better way to handle the above example is to actually study the fetch
refspecs to deduce the candidate remote-tracking branches for "foo"; i.e.
assume "foo" is a remote branch being fetched, and then map "refs/heads/foo"
through the refspecs in order to get the corresponding remote-tracking
branches "refs/remotes/origin/foo" and "refs/remotes/frotz/nitfol/foo".
Finally we check which of these happens to exist in the local repo, and
if there is exactly one, we have an unambiguous match for "git checkout foo",
and may proceed.

This fixes most of the failing tests introduced in the previous patch.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-21 15:14:41 -07:00
Nguyễn Thái Ngọc Duy 08d595dc1c checkout: add --ignore-skip-worktree-bits in sparse checkout mode
"git checkout -- <paths>" is usually used to restore all modified
files in <paths>. In sparse checkout mode, this command is overloaded
with another meaning: to add back all files in <paths> that are
excluded by sparse patterns.

As the former makes more sense for day-to-day use. Switch it to the
default and the latter enabled with --ignore-skip-worktree-bits.

While at there, add info/sparse-checkout to gitrepository-layout.txt

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-15 08:54:45 -07:00
Thomas Ackermann 2de9b71138 Documentation: the name of the system is 'Git', not 'git'
Signed-off-by: Thomas Ackermann <th.acker@arcor.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-01 13:53:33 -08:00
Chris Rorvick 00bb4378c7 Documentation/git-checkout.txt: document 70c9ac2 behavior
Document the behavior implemented in 70c9ac2 (DWIM "git checkout
frotz" to "git checkout -b frotz origin/frotz").

Signed-off-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-18 11:07:44 -08:00
Chris Rorvick e1cdf63316 Documentation/git-checkout.txt: clarify usage
The forms of checkout that do not take a path are lumped together in
the DESCRIPTION section, but the description for this group is
dominated by explanation of the -b|-B form.

Split these apart for more clarity.

Signed-off-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-18 11:04:52 -08:00
Junio C Hamano 9d0b9ed99f Merge branch 'jc/maint-checkout-fileglob-doc'
Updated with help from Peff.

* jc/maint-checkout-fileglob-doc:
  gitcli: contrast wildcard given to shell and to git
  gitcli: formatting fix
  Document file-glob for "git checkout -- '*.c'"
2012-09-12 14:22:08 -07:00
Junio C Hamano 9192ece94b Merge branch 'jc/maint-doc-checkout-b-always-takes-branch-name'
The synopsis said "checkout [-B branch]" to make it clear the branch
name is a parameter to the option, but the heading for the option
description was "-B::", not "-B branch::", making the documentation
misleading.  There may be room in documentation pages of other
commands for similar improvements.

* jc/maint-doc-checkout-b-always-takes-branch-name:
  doc: "git checkout -b/-B/--orphan" always takes a branch name
2012-09-07 11:09:36 -07:00
Junio C Hamano caae319e49 Document file-glob for "git checkout -- '*.c'"
Just like we give a similar example in "git add" documentation.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-04 08:36:33 -07:00
Junio C Hamano 45aaf0310f doc: "git checkout -b/-B/--orphan" always takes a branch name
While the synopsis section makes it clear that the new branch name
is the parameter to these flags, the option description did not.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-26 11:40:08 -07:00
Jeff King 6cf378f0cb docs: stop using asciidoc no-inline-literal
In asciidoc 7, backticks like `foo` produced a typographic
effect, but did not otherwise affect the syntax. In asciidoc
8, backticks introduce an "inline literal" inside which markup
is not interpreted. To keep compatibility with existing
documents, asciidoc 8 has a "no-inline-literal" attribute to
keep the old behavior. We enabled this so that the
documentation could be built on either version.

It has been several years now, and asciidoc 7 is no longer
in wide use. We can now decide whether or not we want
inline literals on their own merits, which are:

  1. The source is much easier to read when the literal
     contains punctuation. You can use `master~1` instead
     of `master{tilde}1`.

  2. They are less error-prone. Because of point (1), we
     tend to make mistakes and forget the extra layer of
     quoting.

This patch removes the no-inline-literal attribute from the
Makefile and converts every use of backticks in the
documentation to an inline literal (they must be cleaned up,
or the example above would literally show "{tilde}" in the
output).

Problematic sites were found by grepping for '`.*[{\\]' and
examined and fixed manually. The results were then verified
by comparing the output of "html2text" on the set of
generated html pages. Doing so revealed that in addition to
making the source more readable, this patch fixes several
formatting bugs:

  - HTML rendering used the ellipsis character instead of
    literal "..." in code examples (like "git log A...B")

  - some code examples used the right-arrow character
    instead of '->' because they failed to quote

  - api-config.txt did not quote tilde, and the resulting
    HTML contained a bogus snippet like:

      <tt><sub></tt> foo <tt></sub>bar</tt>

    which caused some parsers to choke and omit whole
    sections of the page.

  - git-commit.txt confused ``foo`` (backticks inside a
    literal) with ``foo'' (matched double-quotes)

  - mentions of `A U Thor <author@example.com>` used to
    erroneously auto-generate a mailto footnote for
    author@example.com

  - the description of --word-diff=plain incorrectly showed
    the output as "[-removed-] and {added}", not "{+added+}".

  - using "prime" notation like:

      commit `C` and its replacement `C'`

    confused asciidoc into thinking that everything between
    the first backtick and the final apostrophe were meant
    to be inside matched quotes

  - asciidoc got confused by the escaping of some of our
    asterisks. In particular,

      `credential.\*` and `credential.<url>.\*`

    properly escaped the asterisk in the first case, but
    literally passed through the backslash in the second
    case.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-26 13:19:06 -07:00
Valentin Haenel a31538e273 git-checkout.txt: better docs for '--patch'
Describe '-p' as a short form of '--patch' in synopsis and options.  Also
refer the reader to the patch mode description of git-add documentation.

Helped-by: Jeff King <peff@peff.net>
Mentored-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Valentin Haenel <valentin.haenel@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-05-05 13:31:11 -07:00
Jeff King 48bb914ed6 doc: drop author/documentation sections from most pages
The point of these sections is generally to:

  1. Give credit where it is due.

  2. Give the reader an idea of where to ask questions or
     file bug reports.

But they don't do a good job of either case. For (1), they
are out of date and incomplete. A much more accurate answer
can be gotten through shortlog or blame.  For (2), the
correct contact point is generally git@vger, and even if you
wanted to cc the contact point, the out-of-date and
incomplete fields mean you're likely sending to somebody
useless.

So let's drop the fields entirely from all manpages except
git(1) itself. We already point people to the mailing list
for bug reports there, and we can update the Authors section
to give credit to the major contributors and point to
shortlog and blame for more information.

Each page has a "This is part of git" footer, so people can
follow that to the main git manpage.
2011-03-11 10:59:16 -05:00
Junio C Hamano 99f45c2a5d Merge branch 'js/detach-doc'
* js/detach-doc:
  git-checkout.txt: improve detached HEAD documentation
2011-02-27 21:58:30 -08:00
Junio C Hamano c0791f365e Merge branch 'uk/checkout-ambiguous-ref'
* uk/checkout-ambiguous-ref:
  Rename t2019 with typo "amiguous" that meant "ambiguous"
  checkout: rearrange update_refs_for_switch for clarity
  checkout: introduce --detach synonym for "git checkout foo^{commit}"
  checkout: split off a function to peel away branchname arg
  checkout: fix bug with ambiguous refs

Conflicts:
	builtin/checkout.c
2011-02-27 21:58:29 -08:00
Jay Soffian be8ef33c1d git-checkout.txt: improve detached HEAD documentation
The detached HEAD state is a source of much confusion for users
new to git. Here we try to document it better.

Reworked from http://article.gmane.org/gmane.comp.version-control.git/138440

Requested-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-21 21:57:19 -08:00
Junio C Hamano 32669671c7 checkout: introduce --detach synonym for "git checkout foo^{commit}"
For example, one might use this when making a temporary merge to
test that two topics work well together.

Patch by Junio, with tests from Jeff King.

[jn: with some extra checks for bogus commandline usage]

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-08 11:14:26 -08:00
Matthieu Moy 29b9a66f28 Change incorrect uses of "remote branch" meaning "remote-tracking"
"remote branch" is a branch hosted in a remote repository, while
"remote-tracking branch" is a copy of such branch, hosted locally.
The distinction is subtle when the copy is up-to-date, but rather
fundamental to understand what "git fetch" and "git push" do.

This patch should fix all incorrect usages in Documentation/ directory.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-11-03 09:20:47 -07:00
Linus Torvalds 442cb08fa0 Fix missing 'does' in man-page for 'git checkout'
Reported-by: Rainer Standke <rainer.standke@krankikom.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-27 15:08:06 -07:00
Jonathan Nieder b9190e7913 Documentation: do not convert ... operator to ellipses
The symmetric difference or merge-base operator ... as used by
rev-list and diff is actually three period characters.  If it
gets replaced by an ellipsis glyph in the manual, that would
stop readers from copying and pasting it.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-20 14:16:51 -07:00
Junio C Hamano 07cd900112 Merge branch 'tc/checkout-B'
* tc/checkout-B:
  builtin/checkout: handle -B from detached HEAD correctly
  builtin/checkout: learn -B
  builtin/checkout: reword hint for -b
  add tests for checkout -b
2010-08-18 11:42:47 -07:00
Junio C Hamano 609eb9f7ff Merge branch 'maint'
* maint:
  Documentation: Spelling fix in protocol-capabilities.txt
  checkout: accord documentation to what git does
  t0005: work around strange $? in ksh when program terminated by a signal
2010-07-11 23:47:29 -07:00
Nicolas Sebrecht 142183d096 checkout: accord documentation to what git does
Signed-off-by: Nicolas Sebrecht <nicolas.s.dev@gmx.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-07-09 16:28:21 -07:00
Tay Ray Chuan 02ac98374e builtin/checkout: learn -B
Internally, --track and --orphan still use the 'safe' -b, not -B.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-25 10:39:58 -07:00
Junio C Hamano 12575b78fb Merge branch 'jn/checkout-doc' into maint
* jn/checkout-doc:
  Documentation/checkout: clarify description
  Documentation/checkout: clarify description
2010-06-22 09:31:47 -07:00
Junio C Hamano f28f04923e Merge branch 'jn/checkout-doc'
* jn/checkout-doc:
  Documentation/checkout: clarify description
  Documentation/checkout: clarify description
2010-06-21 06:02:42 -07:00
Junio C Hamano 5bebcd4ecb Merge branch 'em/checkout-orphan'
* em/checkout-orphan:
  log_ref_setup: don't return stack-allocated array
  bash completion: add --orphan to 'git checkout'
  t3200: test -l with core.logAllRefUpdates options
  checkout --orphan: respect -l option always
  refs: split log_ref_write logic into log_ref_setup
  Documentation: alter checkout --orphan description
2010-06-21 06:02:41 -07:00
Jonathan Nieder b831deda17 Documentation/checkout: clarify description
git checkout can be used to switch branches and to retrieve files from
the index or an arbitrary tree.  Split the description into
subsections corresponding to each mode to make each use easier to
understand.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-11 08:47:48 -07:00
Erick Mattos feb98d1342 Documentation: alter checkout --orphan description
The present text is a try to enhance description accuracy.  It is a
merge of the rewritten text made by native english speaker Chris Johnsen
and further changes of Junio.  It came from the last thread messages of
--orphan patch.

Signed-off-by: Erick Mattos <erick.mattos@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-02 11:16:48 -07:00
Junio C Hamano bdc4204119 Merge branch 'maint'
* maint:
  git-compat-util.h: use apparently more common __sgi macro to detect SGI IRIX
  Documentation: A...B shortcut for checkout and rebase
  Documentation/pretty-{formats,options}: better reference for "format:<string>"
2010-06-02 10:17:26 -07:00
Michael J Gruber 873c347205 Documentation: A...B shortcut for checkout and rebase
Describe the A...B shortcuts for checkout and rebase [-i] which were
introduced in these commits:

619a64e ("checkout A...B" switches to the merge base between A and B, 2009-10-18)
61dfa1b ("rebase --onto A...B" replays history on the merge base between A and B, 2009-11-20)
230a456 (rebase -i: teach --onto A...B syntax, 2010-01-07)

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-02 10:03:53 -07:00
Jonathan Nieder c5b41519c7 Documentation/checkout: clarify description
To the first-time reader, it may not be obvious that ‘git checkout’
has two modes, nor that if no branch is specified it will read
from the index.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-05-31 17:50:03 -07:00
Erick Mattos 9db5ebf402 git checkout: create unparented branch by --orphan
Similar to -b, --orphan creates a new branch, but it starts without any
commit.  After running "git checkout --orphan newbranch", you are on a
new branch "newbranch", and the first commit you create from this state
will start a new history without any ancestry.

"git checkout --orphan" keeps the index and the working tree files
intact in order to make it convenient for creating a new history whose
trees resemble the ones from the original branch.

When creating a branch whose trees have no resemblance to the ones from
the original branch, it may be easier to start work on the new branch by
untracking and removing all working tree files that came from the
original branch, by running a 'git rm -rf .' immediately after running
"checkout --orphan".

Signed-off-by: Erick Mattos <erick.mattos@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-21 16:43:30 -07:00
Junio C Hamano 54f0bdc811 Merge branch 'tr/reset-checkout-patch'
* tr/reset-checkout-patch:
  stash: simplify defaulting to "save" and reject unknown options
  Make test case number unique
  tests: disable interactive hunk selection tests if perl is not available
  DWIM 'git stash save -p' for 'git stash -p'
  Implement 'git stash save --patch'
  Implement 'git checkout --patch'
  Implement 'git reset --patch'
  builtin-add: refactor the meat of interactive_add()
  Add a small patch-mode testing library
  git-apply--interactive: Refactor patch mode code
  Make 'git stash -k' a short form for 'git stash save --keep-index'
2009-09-07 15:24:38 -07:00
René Scharfe f7aec129fa UI consistency: allow --force for where -f means force
git branch, checkout, clean, mv and tag all have an option -f to override
certain checks.  This patch makes them accept the long option --force as
a synonym.

While we're at it, document that checkout support --quiet as synonym for
its short option -q.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-29 14:08:03 -07:00
Thomas Rast 4f353658b9 Implement 'git checkout --patch'
This introduces a --patch mode for git-checkout.  In the index usage

  git checkout --patch -- [files...]

it lets the user discard edits from the <files> at the granularity of
hunks (by selecting hunks from 'git diff' and then reverse applying
them to the worktree).

We also accept a revision argument.  In the case

  git checkout --patch HEAD -- [files...]

we offer hunks from the difference between HEAD and the worktree, and
reverse applies them to both index and worktree, allowing you to
discard staged changes completely.  In the non-HEAD usage

  git checkout --patch <revision> -- [files...]

it offers hunks from the difference between the worktree and
<revision>.  The chosen hunks are then applied to both index and
worktree.

The application to worktree and index is done "atomically" in the
sense that we first check if the patch applies to the index (it should
always apply to the worktree).  If it does not, we give the user a
choice to either abort or apply to the worktree anyway.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-15 15:18:05 -07:00
Jeff King 0808723b50 docs/checkout: clarify what "non-branch" means
In the code we literally stick "refs/heads/" on the front
and see if it resolves, so that is probably the best
explanation.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-13 09:08:16 -07:00
Jeff King 76cfadfc17 doc/checkout: split checkout and branch creation in synopsis
These can really be thought of as two different modes, since
the "<branch>" parameter is treated differently in the two
(in one it is the branch to be checked out, but in the other
it is really a start-point for branch creation).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-13 09:06:34 -07:00
Jeff King 26d22dc64a doc/checkout: refer to git-branch(1) as appropriate
Most of description for the branch creation options is
simply cut and paste from git-branch. There are two reasons
to fix this:

  1. It can grow stale with respect to what's in "git
     branch" (which it is now is).

  2. It is not just an implementation detail, but rather the
     desired mental model for the command that we are using
     "git branch" here. Being explicit about that can help
     the user understand what is going on.

It also makes sense to strip the branch creation options
from the synopsis, as they are making it a long,
hard-to-read line. They are still easily discovered by
reading the options list, and --track is explicitly
referenced when branch creation is described.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-13 09:04:50 -07:00
Jeff King 167d744543 doc: refer to tracking configuration as "upstream"
The term "tracking" often creates confusion between remote
tracking branches and local branches which track a remote
branch. The term "upstream" captures more clearly the idea
of "branch A is based on branch B in some way", so it makes
sense to mention it.

At the same time, upstream branches are used for more
than just git-pull these days; let's mention that here.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-13 09:02:18 -07:00
Jeff King 70e966477a doc: clarify --no-track option
It is not really about ignoring the config option; it is
about turning off tracking, _even if_ the config option is
set.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-13 09:01:00 -07:00
Junio C Hamano 6da14ee14f Merge branch 'maint'
* maint:
  Change double quotes to single quotes in message
  Documentation: clarify .gitattributes search
  git-checkout.txt: clarify that <branch> applies when no path is given.
  git-checkout.txt: fix incorrect statement about HEAD and index

Conflicts:
	Documentation/git-checkout.txt
2009-04-07 23:05:43 -07:00
Junio C Hamano 747f9d30ed Merge branch 'maint-1.6.1' into maint
* maint-1.6.1:
  Documentation: clarify .gitattributes search
  git-checkout.txt: clarify that <branch> applies when no path is given.
  git-checkout.txt: fix incorrect statement about HEAD and index
2009-04-07 23:05:14 -07:00
Junio C Hamano aa41cf8f43 Merge branch 'maint-1.6.0' into maint-1.6.1
* maint-1.6.0:
  Documentation: clarify .gitattributes search
  git-checkout.txt: clarify that <branch> applies when no path is given.
  git-checkout.txt: fix incorrect statement about HEAD and index
2009-04-07 22:51:14 -07:00
Matthieu Moy 39470cf961 git-checkout.txt: clarify that <branch> applies when no path is given.
Otherwise, the sentence "Defaults to HEAD." can be mis-read to mean
that "git checkout -- hello.c" checks-out from HEAD.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-07 21:57:12 -07:00
Matthieu Moy ce8936c342 git-checkout.txt: fix incorrect statement about HEAD and index
The command "git checkout" checks out from the index by default, not
HEAD (the introducing comment were correct, but the detailled
explanation added below were not).

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-07 21:56:41 -07:00
Chris Johnsen dcb11263bc Documentation: remove extra quoting/emphasis around literal texts
If literal text (asciidoc `...`) can be rendered in a differently from
normal text for each output format (man, HTML), then we do not need
extra quotes or other wrapping around inline literal text segments.

config.txt

  Change '`...`' to `...`. In asciidoc, the single quotes provide
  emphasis, literal text should be distintive enough.

  Change "`...`" to `...`. These double quotes do not work if present
  in the described config value, so drop them.

git-checkout.txt

  Change "`...`" to `...` or `"..."`. All instances are command line
  argument examples. One "`-`" becomes `-`. Two others are involve
  curly braces, so move the double quotes inside the literal region to
  indicate that they might need to be quoted on the command line of
  certain shells (tcsh).

git-merge.txt

  Change "`...`" to `...`. All instances are used to describe merge
  conflict markers. The quotes should are not important.

git-rev-parse.txt

  Change "`...`" to `...`. All instances are around command line
  arguments where no in-shell quoting should be necessary.

gitcli.txt

  Change `"..."` to `...`. All instances are around command line
  examples or single command arguments. They do not semanticly belong
  inside the literal text, and they are not needed outside it.

glossary-content.txt
user-manual.txt

  Change "`...`" to `...`. All instances were around command lines.

Signed-off-by: Chris Johnsen <chris_johnsen@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-03-17 14:16:44 -07:00
Michael J Gruber c7cb12b86c Typo and language fixes for git-checkout.txt
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-03-10 22:54:53 -07:00
Thomas Rast 696acf45f9 checkout: implement "-" abbreviation, add docs and tests
Have '-' mean the same as '@{-1}', i.e., the last branch we were on.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-17 18:37:21 -08:00
Markus Heidelberg ec9f0ea3e6 Documentation: sync example output with git output
Don't confuse the user with old git messages.

Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-12-19 11:55:33 -08:00
Nanako Shiraishi ecc03c1c6d Clarify documentation of "git checkout <tree-ish> paths" syntax
The SYNOPSIS section of the manual writes:

    git checkout [options] [<tree-ish>] [--] <paths>...

but the DESCRIPTION says that this form checks the paths out "from the
index, or from a named commit."  A later sentence refers to the same
argument as "<tree-ish> argument", but it is not clear that these two
sentences are talking about the same command line argument for first-time
readers.

Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-12-17 22:00:54 -08:00
Fredrik Skolmli 971e83528d Documentation: Spelling fix
Signed-off-by: Fredrik Skolmli <fredrik@frsk.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-10-19 13:08:14 -07:00
Shawn O. Pearce 9ba929ed65 Merge branch 'jc/better-conflict-resolution'
* jc/better-conflict-resolution:
  Fix AsciiDoc errors in merge documentation
  git-merge documentation: describe how conflict is presented
  checkout --conflict=<style>: recreate merge in a non-default style
  checkout -m: recreate merge when checking out of unmerged index
  git-merge-recursive: learn to honor merge.conflictstyle
  merge.conflictstyle: choose between "merge" and "diff3 -m" styles
  rerere: understand "diff3 -m" style conflicts with the original
  rerere.c: use symbolic constants to keep track of parsing states
  xmerge.c: "diff3 -m" style clips merge reduction level to EAGER or less
  xmerge.c: minimum readability fixups
  xdiff-merge: optionally show conflicts in "diff3 -m" style
  xdl_fill_merge_buffer(): separate out a too deeply nested function
  checkout --ours/--theirs: allow checking out one side of a conflicting merge
  checkout -f: allow ignoring unmerged paths when checking out of the index

Conflicts:
	Documentation/git-checkout.txt
	builtin-checkout.c
	builtin-merge-recursive.c
	t/t7201-co.sh
2008-09-29 10:15:07 -07:00
Junio C Hamano eac5a40151 checkout --conflict=<style>: recreate merge in a non-default style
This new option does essentially the same thing as -m option when checking
unmerged paths out of the index, but it uses the specified style instead
of configured merge.conflictstyle.

Setting "merge.conflictstyle" to "diff3" is usually less useful than using
the default "merge" style, because the latter allows a conflict that
results by both sides changing the same region in a very similar way to
get simplified substancially by reducing the common lines.  However, when
one side removed a group of lines (perhaps a function was moved to some
other file) while the other side modified it, the default "merge" style
does not give any clue as to why the hunk is left conflicting.  You would
need the original to understand what is going on.

The recommended use would be not to set merge.conflictstyle variable so
that you would usually use the default "merge" style conflict, and when
the result in a path in a particular merge is too hard to understand, use
"git checkout --conflict=diff3 $path" to check it out with the original to
review what is going on.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-31 20:09:21 -07:00
Junio C Hamano 0cf8581e33 checkout -m: recreate merge when checking out of unmerged index
This teaches git-checkout to recreate a merge out of unmerged
index entries while resolving conflicts.

With this patch, checking out an unmerged path from the index
now have the following possibilities:

 * Without any option, an attempt to checkout an unmerged path
   will atomically fail (i.e. no other cleanly-merged paths are
   checked out either);

 * With "-f", other cleanly-merged paths are checked out, and
   unmerged paths are ignored;

 * With "--ours" or "--theirs, the contents from the specified
   stage is checked out;

 * With "-m" (we should add "--merge" as synonym), the 3-way merge
   is recreated from the staged object names and checked out.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-30 19:57:55 -07:00
Junio C Hamano 38901a4837 checkout --ours/--theirs: allow checking out one side of a conflicting merge
This lets you to check out 'our' (or 'their') version of an
unmerged path out of the index while resolving conflicts.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-30 19:28:45 -07:00
Junio C Hamano db9410990e checkout -f: allow ignoring unmerged paths when checking out of the index
Earlier we made "git checkout $pathspec" to atomically refuse
the operation of $pathspec matched any path with unmerged
stages.  This patch allows:

    $ git checkout -f a b c

to ignore, instead of error out on, such unmerged paths.  The
fix to prevent checkout of an unmerged path from random stages
is still there.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-30 19:16:12 -07:00
Alex Riesen 9188ed8962 Extend "checkout --track" DWIM to support more cases
The code handles additionally "refs/remotes/<something>/name",
"remotes/<something>/name", and "refs/<namespace>/name".

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-22 17:18:26 -07:00
Johannes Schindelin bb0ceb6264 checkout --track: make up a sensible branch name if '-b' was omitted
What does the user most likely want with this command?

	$ git checkout --track origin/next

Exactly.  A branch called 'next', that tracks origin's branch 'next'.
Make it so.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-11 16:37:28 -07:00
SZEDER Gábor b302ddd2f8 checkout: mention '--' in the docs
'git checkout' uses '--' to separate options from paths, but it was not
mentioned in the documentation

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-24 23:29:38 -07:00
Jonathan Nieder ba020ef5eb manpages: italicize git command names (which were in teletype font)
The names of git commands are not meant to be entered at the
commandline; they are just names. So we render them in italics,
as is usual for command names in manpages.

Using

	doit () {
	  perl -e 'for (<>) { s/\`(git-[^\`.]*)\`/'\''\1'\''/g; print }'
	}
	for i in git*.txt config.txt diff*.txt blame*.txt fetch*.txt i18n.txt \
	        merge*.txt pretty*.txt pull*.txt rev*.txt urls*.txt
	do
	  doit <"$i" >"$i+" && mv "$i+" "$i"
	done
	git diff

.

Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-05 11:24:40 -07:00
Jonathan Nieder 483bc4f045 Documentation formatting and cleanup
Following what appears to be the predominant style, format
names of commands and commandlines both as `teletype text`.

While we're at it, add articles ("a" and "the") in some
places, italicize the name of the command in the manual page
synopsis line, and add a comma or two where it seems appropriate.

Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-01 17:20:16 -07:00
Jonathan Nieder b1889c36d8 Documentation: be consistent about "git-" versus "git "
Since the git-* commands are not installed in $(bindir), using
"git-command <parameters>" in examples in the documentation is
not a good idea. On the other hand, it is nice to be able to
refer to each command using one hyphenated word. (There is no
escaping it, anyway: man page names cannot have spaces in them.)

This patch retains the dash in naming an operation, command,
program, process, or action. Complete command lines that can
be entered at a shell (i.e., without options omitted) are
made to use the dashless form.

The changes consist only of replacing some spaces with hyphens
and vice versa. After a "s/ /-/g", the unpatched and patched
versions are identical.

Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-01 17:20:15 -07:00
Stephan Beyer 3240240ff4 Docs: Use "-l::\n--long\n" format in OPTIONS sections
The OPTIONS section of a documentation file contains a list
of the options a git command accepts.

Currently there are several variants to describe the case that
different options (almost) do the same in the OPTIONS section.

Some are:

 -f, --foo::
 -f|--foo::
 -f | --foo::

But AsciiDoc has the special form:

 -f::
 --foo::

This patch applies this form to the documentation of the whole git suite,
and removes useless em-dash prevention, so \--foo becomes --foo.

Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-08 13:46:38 -07:00
Christian Couder 9e1f0a85c6 documentation: move git(7) to git(1)
As the "git" man page describes the "git" command at the end-user
level, it seems better to move it to man section 1.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-06 11:18:28 -07:00
Miklos Vajna 498a6e7eaa git checkout: add -t alias for --track
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-27 13:19:33 -07:00
Julian Phillips 76ce946294 Documentation/git-checkout: Update summary to reflect current abilities
For a while now, git-checkout has been more powerful than the man-page
summary would suggest (the main text does describe the new features),
so update the summary to hopefully better reflect the current
functionality.  Also update the glossary description of the word checkout.

Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-25 00:00:07 -07:00
Jay Soffian 572fc81d21 doc: documentation update for the branch track changes
Documents the branch.autosetupmerge=always setting and usage of --track
when branching from a local branch.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-19 21:22:29 -08:00