From: Alexey Shumkin <alex.crezoff@gmail.com>
To: Jvsrvcs <jvsrvcs@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Git: Unexpected behaviour?
Date: Sat, 12 Nov 2011 12:32:34 +0400 [thread overview]
Message-ID: <20111112123234.17ab4426@zappedws> (raw)
In-Reply-To: <1321044904175-6986736.post@n2.nabble.com>
the same situation and question were discussed and explained one
month earlier
take a look
http://thread.gmane.org/gmane.comp.version-control.git/183464
> Unexpected git behaviour
>
> ---
> # First create a local git repo
>
> $mkdir gitexample
> $git config --global user.name "my name"
> $git config --global user.email "me@me.com"
> $git init
> $git add .
> $git commit -m 'initial commit'
>
> # Create/Edit an empty file
> $vi readme.txt
>
> # add a single line: "this was added in the master branch."
> $git commit -a
>
> # create and checkout a new branch (from master)
> $git branch test
> $git checkout test
>
> # edit the readme.txt file and do not commit
> # add the text: "this was added in the test branch.", save and exit
> $vi readme.txt
>
> #now switch back to master
> $git checkout master
> $cat readme.txt
>
> #You will see both lines in the master.
>
> Question #1:
> Why was this line added in the *master branch?
>
>
> --- even further surprising
> In the master branch, now do a commit
> $git commit -a
>
> cat readme.txt ( you will see the line in the master now that was
> added in the test branch )
>
> Question #2:
> Why did this happen?
>
> # Now switch back to the test branch
> $git checkout test
> $cat readme.txt
>
> You will only see the one line: "This was added in the master branch"
>
> Question #3:
> Why did this happen?
>
> and NOT the line added in that branch: "this was added in the test
> branch" <= this line is gone
>
> What is the reason for this?
>
> 1) Why do I see uncommitted changes in the branches made off master
> in the master branch?
> 2) Why, if I commit them in the master, do the disappear in the
> branch in which they were made?
>
> This is confusing, I would think the * master branch would be left
> untouched. This would solve issue #2.
>
>
> --
> View this message in context:
> http://git.661346.n2.nabble.com/Git-Unexpected-behaviour-tp6986736p6986736.html
> Sent from the git mailing list archive at Nabble.com.
prev parent reply other threads:[~2011-11-12 8:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-11 20:55 Git: Unexpected behaviour? Jvsrvcs
2011-11-11 21:03 ` Carlos Martín Nieto
[not found] ` <CAPZPVFb-VbTfkuyg4KtTsaWiNvd37GHeH7crPtqv1fKRbwuyfQ@mail.gmail.com>
2011-11-11 21:04 ` Eugene Sajine
2011-11-11 21:09 ` Jvsrvcs
2011-11-11 21:14 ` Taylor Hedberg
2011-11-11 21:25 ` Gelonida N
2011-11-11 21:31 ` Chris Packham
2011-11-12 0:24 ` J.V.
2011-11-12 8:25 ` Chris Packham
2011-11-12 19:37 ` Junio C Hamano
2011-11-14 17:20 ` Martin von Zweigbergk
2011-11-14 20:55 ` Junio C Hamano
2011-11-14 21:33 ` Jakub Narebski
2011-11-12 8:32 ` Alexey Shumkin [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=20111112123234.17ab4426@zappedws \
--to=alex.crezoff@gmail.com \
--cc=git@vger.kernel.org \
--cc=jvsrvcs@gmail.com \
/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).