[RFC] Reverting individual files to HEAD

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

 



Hi,

What's the best way to revert individual files with git?

To revert a whole tree, I can use "git reset --hard", but it refuses
to do a partial reset.

At the moment, I use either

$ git diff file | patch -R -p1

or

$ git show HEAD:file > file

(followed by git-add file in both cases)

I realize I can also do

$ git reset HEAD file
$ git checkout file

But all of them sound rather ugly and unintuitive for something I
consider to be a relatively common operation.

Cogito had a cg-restore command which did roughy the
"git-show ... > file" above.

Either I missed something obvious (in which case, I'll be glad to add
a FAQ about that), or git porcelain should include something to make
it simpler to revert individual files.

I'd rather avoid adding yet-another-command, but I think
"git reset --hard" could be make to accept partial revert in case it
reverts to the HEAD (I understand it cannot otherwise, since the whole
tree has to point to the same HEAD).

Does this sound OK to you? Any better suggestion?

-- 
Matthieu
-
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]

  Powered by Linux