From: sean <seanlkml@sympatico.ca>
To: walt <wa1ter@myrealbox.com>
Cc: git@vger.kernel.org
Subject: Re: My first git success [not quite]
Date: Sat, 14 Jan 2006 10:55:04 -0500 [thread overview]
Message-ID: <BAYC1-PASMTP10B423DC1B2FC1F8C9992BAE190@CEZ.ICE> (raw)
Message-ID: <20060114105504.157248db.seanlkml@sympatico.ca> (raw)
In-Reply-To: <dqb5vg$a09$1@sea.gmane.org>
On Sat, 14 Jan 2006 07:39:28 -0800
walt <wa1ter@myrealbox.com> wrote:
> Linus Torvalds wrote:
> >
> > On Fri, 13 Jan 2006, walt wrote:
> >> And it was all so easy I never broke a sweat. Amazing!
>
> > ...Most people don't bother to
> > explain their problems well...
>
> I see I still have a problem: my mental model of how git
> works is still wrong.
>
> I used 'git-checkout -b test' to create a disposable place
> to test the patch I was given.
>
> Okay, making sure I'm now sitting in 'test', I apply the
> patch to foo.c and do my testing.
>
> Now, intending to delete my 'test' branch, I do git-checkout
> master. My mental model predicts that 'master' should still
> be identical to 'origin' because I did the patching in 'test'.
> Am I right so far?
>
> The problem I see is that, after switching back to 'master',
> foo.c is the patched version, not your original version. I
> figured that the git-checkout would overwrite any changes I
> made to foo.c, but that doesn't seem to be the case. To get
> your original version back I had to delete foo.c and do a
> git-checkout foo.c (or git-checkout -f master).
>
> So, I clearly don't understand what git-checkout does. It
> doesn't seem to touch the already-checked-out sources at
> all, which is what I would expect it to do.
>
> Can someone hit me with the clue-stick here? Thanks!
>
Hi Walt,
When you switch branches _uncommitted_ changes will stay in
your working directory. This lets you change to a different
branch before committing something you're working on for
instance. So likely, even though you had switched to your
test branch to apply the patch, you didn't actually commit
it into that branch before switching back to master.
Here's a little example that should show the difference:
Create a test repo:
$ mkdir walt ; cd walt
$ git-init-db
defaulting to local storage area
Create a simple file and commit it on the master branch:
$ echo A > file
$ git add file
$ git commit -m "initial"
Committing initial tree a9e3325a07117aa5381e044a8d96c26eb30d729d
Create and checkout a new branch named "test":
$ git checkout -b test
$ git branch
master
* test
Modify (ie. patch) the file:
$ echo B > file
$ cat file
B
Now, if you switch back to the master branch, the file is still patched:
$ git checkout master
$ cat file
B
Switch back to the test branch and commit the change this time:
$ git checkout test
$ git commit -m "test branch" file
$ cat file
B
Now, this time when you switch back to master, you'll get what you expect:
$ git checkout master
$ cat file
A
HTH,
Sean
next prev parent reply other threads:[~2006-01-14 15:59 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-13 14:51 My first git success walt
2006-01-13 17:11 ` Linus Torvalds
2006-01-13 18:57 ` Randal L. Schwartz
2006-01-13 19:37 ` Junio C Hamano
2006-01-13 20:14 ` Peter Eriksen
2006-01-14 15:39 ` My first git success [not quite] walt
[not found] ` <20060114105504.157248db.seanlkml@sympatico.ca>
2006-01-14 15:55 ` sean [this message]
2006-01-14 17:18 ` walt
2006-01-14 17:48 ` Randal L. Schwartz
2006-01-14 20:31 ` Junio C Hamano
2006-01-14 19:25 ` Linus Torvalds
2006-01-14 20:41 ` walt
2006-01-14 20:49 ` Junio C Hamano
2006-01-14 21:57 ` Linus Torvalds
2006-01-15 10:44 ` Junio C Hamano
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=BAYC1-PASMTP10B423DC1B2FC1F8C9992BAE190@CEZ.ICE \
--to=seanlkml@sympatico.ca \
--cc=git@vger.kernel.org \
--cc=wa1ter@myrealbox.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).