* How to undo changes?
@ 2010-04-29 1:08 Lin Mac
2010-04-29 1:29 ` Erik Faye-Lund
0 siblings, 1 reply; 2+ messages in thread
From: Lin Mac @ 2010-04-29 1:08 UTC (permalink / raw)
To: git
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?
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?
I run into situation 1 from time to time. Luckily I have never ran
into situation 2, but would like to know the recovery ways.
Thanks in advance.
Best Regards,
Mac Lin
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How to undo changes?
2010-04-29 1:08 How to undo changes? Lin Mac
@ 2010-04-29 1:29 ` Erik Faye-Lund
0 siblings, 0 replies; 2+ messages in thread
From: Erik Faye-Lund @ 2010-04-29 1:29 UTC (permalink / raw)
To: Lin Mac; +Cc: git
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-04-29 1:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-29 1:08 How to undo changes? Lin Mac
2010-04-29 1:29 ` Erik Faye-Lund
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).