git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Erik Faye-Lund <kusmabite@googlemail.com>
To: Lin Mac <mkl0301@gmail.com>
Cc: git <git@vger.kernel.org>
Subject: Re: How to undo changes?
Date: Thu, 29 Apr 2010 03:29:25 +0200	[thread overview]
Message-ID: <g2z40aa078e1004281829o446bce44r165aa59c98969043@mail.gmail.com> (raw)
In-Reply-To: <l2l10d816431004281808s79a559e6p308052c788c9a4ca@mail.gmail.com>

On Thu, Apr 29, 2010 at 3:08 AM, Lin Mac <mkl0301@gmail.com> wrote:
> Hi,
>
> 1.
> I have multiple files modified, but would like to undo the changes in
> one of the changed files.
> "git reset --hard" do not accept single files. So I used to use "git
> diff <file> | patch -p X", but X cannot be know until I checked the
> patch and know the path relationship. Is there other way to do it?

git checkout -- <file>

>
> 2.
> Sometimes I delete old unused branches with "git branch -D <branch>",
> but I just realized theren't a reflog log for such operation. If the
> branch is the only reference to the logs, deleting the branch makes
> the commits become dangling commits.  How could I recover those
> commit?
>

Run "git fsck --lost-found" to list the SHA-1s of all dangling objects.

But make sure you've taken a backup of the repo first, just in case
something gets messed up further ;)

-- 
Erik "kusma" Faye-Lund

      reply	other threads:[~2010-04-29  1:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-29  1:08 How to undo changes? Lin Mac
2010-04-29  1:29 ` Erik Faye-Lund [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=g2z40aa078e1004281829o446bce44r165aa59c98969043@mail.gmail.com \
    --to=kusmabite@googlemail.com \
    --cc=git@vger.kernel.org \
    --cc=kusmabite@gmail.com \
    --cc=mkl0301@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).