Re: How to undo changes?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 29, 2010 at 3:08 AM, Lin Mac <mkl0301@xxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]