git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "r.ductor@gmail.com" <r.ductor@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jonathan Nieder <jrnieder@gmail.com>,
	git@vger.kernel.org, Jeff King <peff@peff.net>
Subject: Re: [PATCH/RFC] Documentation/checkout: explain behavior wrt local changes
Date: Fri, 7 Jan 2011 15:27:42 +0100	[thread overview]
Message-ID: <201101071527.42544.r.ductor@gmail.com> (raw)
In-Reply-To: <7vtyhl8t5y.fsf@alter.siamese.dyndns.org>

Dear all

I'm a beginner git user trying to defend the beginners' party. Using Jonathan's explanations (and some educated guess on git behavior) I tried to concoct the man git-checkout documentation I would have liked to read, which is somewhat more explicit than Jonathan's patch. If you want to implement/improve it please double check it (and maybe warn me about my own errors). If you are happy about that I will try to send more suggestions. Thanks for your time and your work.

riccardo   

git checkout [<branch>]
git checkout -b|-B <new_branch> [<start point>]

     Tries to change the current HEAD to <branch> (or <start point>) and to safely update the working tree and the index.
     If there exist files having three distinct contents in the current commit, in the new branch and in the working tree, then the operation is canceled and all state is preserved.
     (This behavior may be changed with the option --merge.) If this is not the case, for all other files it acts as follows.  
       - Files not differing between the current commit and the new branch: their contents in the working tree (and eventually in the index) are left unchanged. 
       - Files in the current commit, unchanged or absent in the working tree, but not present in the new branch are removed from the working tree and from the index.
       - Files in the new branch but not in the current commit are added to the working tree and to the index (if they were already there they must have had the same contents by hypothesis).
       - Files in the working tree or in the index that are absent in the current commit and in the new branch are left unchanged.
    
    If -b is given, ...



On Friday 07 January 2011 01:16:25 Junio C Hamano wrote:
> Jonathan Nieder <jrnieder@gmail.com> writes:
> 
> >  'git checkout' [<branch>]::
> >  'git checkout' -b|-B <new_branch> [<start point>]::
> >  
> > -	This form switches branches by updating the index, working
> > -	tree, and HEAD to reflect the specified branch.
> > +	This form switches branches by changing `HEAD` and updating the
> > +	tracked files to the specified branch.  'git checkout' will
> > +	stop without doing anything if local changes overlap with
> > +	changes to the tracked files.  (Any local changes that do not
> > +	overlap with changes from `HEAD` to the specified branch will
> > +	be preserved.)
> 

      reply	other threads:[~2011-01-07 15:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20110106154418.3348.29438.reportbug@localhost>
2011-01-06 17:35 ` git checkout branch behaves differently from what specified in man page Jonathan Nieder
2011-01-06 22:52   ` [PATCH/RFC] Documentation/checkout: explain behavior wrt local changes Jonathan Nieder
2011-01-07  0:16     ` Junio C Hamano
2011-01-07 14:27       ` r.ductor [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201101071527.42544.r.ductor@gmail.com \
    --to=r.ductor@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).