From: Junio C Hamano <junkio@cox.net>
To: "Chris Lee" <clee@kde.org>
Cc: git@vger.kernel.org
Subject: Re: Simple UI question...
Date: Sun, 07 Jan 2007 03:30:56 -0800 [thread overview]
Message-ID: <7vodpb13bj.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <204011cb0701070302y54837c5bp967e2cddd3fb655d@mail.gmail.com> (Chris Lee's message of "Sun, 7 Jan 2007 03:02:59 -0800")
"Chris Lee" <clee@kde.org> writes:
> Eric Anholt suggested 'git checkout -b temporary-branch-name
> $sha1sum'; davej suggested 'git-read-tree $sha1sum &&
> git-checkout-index -a -f' but for some reason, neither of these
> commands seems to do exactly as I expect.
These two do vastly different things (but the latter is flawed
and does _not_ do what it is trying to do).
- If this checkout is just to look-see, and if you are on a
branch that is precious to you (say, you intend to keep
importing from svn or other repository onto that branch),
then you should use a temporary branch. Eric's suggestion is
this approach -- but "git checkout -b $branch $start" is
about CREATING a new branch, so once you used the temporary
branch name, you cannot expect the same command line with
only different starting point to work. In other words, I
suspect you saw "it doesn't work" because you did this:
$ git checkout -b foo $commit1
$ git checkout -b foo $commit2
and got an error message from the second one.
- If you do not mind trashing the current branch, then "git
reset --hard" is what you want, and what you said was Dave's
suggestion is an incorrectly spelled version of old timer's
way to do what "git reset --hard" does by hand.
Assuming that you do not want to trash your branch (and you
usually don't), the correct sequence is first do:
$ git checkout -b look-see
This creates a new branch "look-see" (the name does not matter
as long as you do not have such a branch) from whatever branch
you happen to be on and switch to it. After this, you will be
on the new "look-see" branch. At which commit this branch
starts does not matter.
Then, whichever commit you would want to check out and look at,
you would do:
$ git reset --hard $commit
This "trashes" look-see branch by moving to that commit -- it
trashes in the sense that it makes the "look-see" branch forget
about all commits that comes after you resetted to, but you do
not care because this branch is temporary branch you created.
Once you are done looking at this commit, you can repeatedly say
"git reset --hard" to move around to look at different commits.
Once you are done, you do not need to be on (nor need) look-see
branch, so get rid of it.
$ git checkout master
$ git branch -D look-see
> ... (The problem I have seen is that, for some
> revisions, the only files I get in the working copy are the files that
> were changed in that commit; the rest of the files in the tree do not
> get checked out.)
This is because the low-level commands in the above example to
mimick "git reset --hard" does is flawed.
If you are curious,...
The way "git-reset --hard" does it (it is just a shell script) is:
git-read-tree --reset -u $rev
but it does other things for safety. Dave apparently learned
git long time before we only had plumbing (set of low-level
commands), so the suggestion did not use Porcelain (higher level
commands) "git-reset"; back then, the correct way to spell that
was:
git-read-tree $rev &&
git-checkout-index -f -q -u -a
but git-read-tree learned -u option and made the second command
in this sequence unnecessary.
In general, you should not have to use git-checkout-index nor
git-read-tree yourself if you are working with today's git.
prev parent reply other threads:[~2007-01-07 11:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-07 11:02 Simple UI question Chris Lee
2007-01-07 11:06 ` Josef "Jeff" Sipek
2007-01-07 11:13 ` Shawn O. Pearce
2007-01-07 11:21 ` Chris Lee
2007-01-07 11:29 ` Shawn O. Pearce
2007-01-07 11:38 ` Chris Lee
2007-01-07 11:40 ` Junio C Hamano
2007-01-07 11:50 ` Chris Lee
2007-01-07 11:30 ` Junio C Hamano [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=7vodpb13bj.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=clee@kde.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.