From: fREW <frioux@gmail.com>
To: "Chris Frey" <cdfrey@foursquare.net>, git@vger.kernel.org
Subject: Re: Deleted files can't be checked back out?
Date: Sun, 25 May 2008 18:37:27 -0500 [thread overview]
Message-ID: <fb3648c60805251637p70bc76fdm1947da6b9bf34ca1@mail.gmail.com> (raw)
In-Reply-To: <20080523062821.GA24411@foursquare.net>
Just FYI, git revert was exactly what I needed. If you want to undo
any commit at all git revert is your friend.
Thanks!
-fREW
On 5/23/08, Chris Frey <cdfrey@foursquare.net> wrote:
> On Thu, May 22, 2008 at 11:28:57PM -0500, fREW wrote:
>> I recently deleted a bunch of files and checked the change into git,
>> and then changed my mind and wanted the files back. I did a
>> git-checkout <file> and got each file back individually. Then I did
>
> I believe you want to undo the change you made (deleting files), not
> just view an old version of the file, which is what checkout does.
>
> You can either add it back yourself, or you can undo the last commit, using
> git-reset.
>
> Here's an example of what you could have done before making further
> changes that you wanted to push:
>
> git rm file
> git commit
> git log # view your change
> git reset --hard HEAD^ # go back to the HEAD before your change
>
> Think of the chain of commits as a long linked list of changes. A branch
> head is just a pointer to the top of that linked list. git-reset allows
> you to point that HEAD to anywhere in the list, even after going back
> in history. The commits are still there, even if HEAD doesn't explicitly
> point to them.
>
> For example, say git log shows commit 1a2b3c4 as HEAD, with commit 7abc983
> as its parent. You can move the HEAD back and forth, like this:
>
> git reset --hard 7abc983
> git log # commit 1a2b3c4 is gone!
> git reset --hard 1a2b3c4
> git log # now it's back!
>
> But in your case, you now have a list of commits that is missing files:
>
> A -> B -> C
> | |
> | (made changes here)
> |
> (deleted files here)
>
> So in this case you likely want to revert commit B, while keeping commit C.
>
> git log # get the commit SHA1, let's say it's 04bcb93
> git revert 04bcb93
>
>
> Take a look at "Git from the bottom up"
> http://www.newartisans.com/blog_files/git.from.bottom.up.php
>
> - Chris
>
>
next prev parent reply other threads:[~2008-05-25 23:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-23 4:28 Deleted files can't be checked back out? fREW
2008-05-23 6:28 ` Chris Frey
2008-05-25 23:37 ` fREW [this message]
2008-05-24 0:43 ` Jakub Narebski
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=fb3648c60805251637p70bc76fdm1947da6b9bf34ca1@mail.gmail.com \
--to=frioux@gmail.com \
--cc=cdfrey@foursquare.net \
--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).