git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dima Kagan <dima.kagan@gmail.com>
To: "Björn Steinbrink" <B.Steinbrink@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: Git branches - confusing behavior
Date: Sun, 11 May 2008 16:04:31 +0300	[thread overview]
Message-ID: <4826EEDF.4010404@gmail.com> (raw)
In-Reply-To: <20080511125722.GA22075@atjola.homenet>

Björn Steinbrink wrote:
> On 2008.05.11 15:33:21 +0300, Dima Kagan wrote:
>>>> Basically I see that the same file I edited on the 'test_branch'
>>>> branch appears to be modified on the 'master' branch as well. This
>>>> behavior is unwanted, of course.
>>>>
>>>> Can someone please tell me, what am doing wrong? Or is this git's
>>>> normal behavior?
>> I just realized that this behavior is even more confusing.  If I
>> commit the file on 'test_branch' and only then 'git checkout master'
>> the changes are not visible on 'master' until I merge. So why should
>> 'master' be affected by uncommitted changes on some branch???
> 
> Uncommitted changes are not on any branch, they are in your working tree
> and/or your index. And actually, SVN does the exact same thing.
> 
> # Create a SVN repository with trunk/ and branches/
> # ----
> $ mkdir svn
> $ cd svn
> $ svnadmin create repo
> $ export REPO="file://$PWD/repo"
> $ svn co $REPO wc
> Checked out revision 0.
> $ cd wc
> $ svn mkdir trunk branches
> A         trunk
> A         branches
> $ svn commit -m init
> Adding         branches
> Adding         trunk
> 
> Committed revision 1.
> $ svn switch $REPO/trunk
> D    trunk
> D    branches
> Updated to revision 1.
> 
> 
> # Create some content in trunk
> # ----
> $ echo 123 > testfile
> $ svn add testfile
> A         testfile
> $ svn commit -m test
> Adding         testfile
> Transmitting file data .
> Committed revision 2.
> 
> 
> # Create a branch
> # ----
> $ svn cp $REPO/trunk $REPO/branches/b1 -m branch
> 
> Committed revision 3.
> 
> 
> # Produce some uncommitted changes on trunk
> # ----
> $ echo 456 > testfile
> $ svn st
> M      testfile
> $ svn diff
> Index: testfile
> ===================================================================
> --- testfile    (revision 2)
> +++ testfile    (working copy)
> @@ -1 +1 @@
> -123
> +456
> 
> 
> # Switch to the branch
> # ----
> $ svn switch $REPO/branches/b1
> At revision 3.
> $ svn st
> M      testfile
> $ svn diff
> Index: testfile
> ===================================================================
> --- testfile    (revision 3)
> +++ testfile    (working copy)
> @@ -1 +1 @@
> -123
> +456
> 
> 
> The uncommitted changes survived the branch change and are still in the
> working tree, in svn just like in git.
> 
> Björn

Yes, I am aware of that, except one rarely works in one directory on multiple svn branches, because the branches are not private. Git's branches can be private, so perhaps this behavior should be different from SVN?

BTW, Is there a way to do 'svn checkout -b new_branch' into a new directory?

  reply	other threads:[~2008-05-11 13:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-11 11:31 Git branches - confusing behavior Dima Kagan
2008-05-11 11:42 ` Jakub Narebski
2008-05-11 11:58   ` Dima Kagan
2008-05-11 12:06     ` David Symonds
2008-05-11 12:11       ` Dima Kagan
2008-05-11 12:13         ` David Symonds
2008-05-11 12:17           ` Dima Kagan
2008-05-11 12:20     ` Steve Frécinaux
     [not found]     ` <f35478f50805110513h15aa462bs9ee35ed4738d3009@mail.gmail.com>
2008-05-11 12:21       ` Dima Kagan
2008-05-11 13:40     ` Jakub Narebski
2008-05-11 12:33   ` Dima Kagan
2008-05-11 12:57     ` Björn Steinbrink
2008-05-11 13:04       ` Dima Kagan [this message]
2008-05-11 13:27         ` Björn Steinbrink
2008-05-11 13:39           ` Dima Kagan
     [not found]             ` <4826F72D.2070205-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-05-11 15:25               ` Patrick Aljord
2008-05-11 15:39             ` Teemu Likonen
2008-05-12  7:49             ` Miles Bader
2008-05-11 14:03         ` Theodore Tso
  -- strict thread matches above, loose matches on Subject: below --
2008-06-30  7:23 Matt Seitz (matseitz)

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=4826EEDF.4010404@gmail.com \
    --to=dima.kagan@gmail.com \
    --cc=B.Steinbrink@gmx.de \
    --cc=git@vger.kernel.org \
    /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).