News for hackers. Stuff that matters.
Re:Git 2.19.0 released by kahlonel on Wednesday September 12, 2018 @11:31AM (#17969770)
As a developer who often needs to revert other developers' screwups (and sometimes my own): "git show COMMIT_ID -- somefile | git apply -R"
Re:Git 2.19.0 released by maccam94 on Wednesday September 12, 2018 @01:26PM (#17971014)
Isn't that the same as `git revert $commit` ?
Re:Git 2.19.0 released by schrodinger on Wednesday September 12, 2018 @02:14PM (#17971462)
I’m guessing that it’s different in that it only reverts one file, not the entire commit.
Re:Git 2.19.0 released by Lord_Zero on Wednesday September 12, 2018 @11:37AM (#17969835)
Git noob here, what does this do? I have read the docs on apply but I don't really understand patches. It sounds like you bundle a bunch of commits and allow someone to use them. But in that case, wuldnt you just push a branch and then the person who needs it can pull and merge it or rebase onto it or cherry pick it?
Re:Git 2.19.0 released by NateEag on Wednesday September 12, 2018 @11:42AM (#17969884)
It undoes the change made to `somefile` in `COMMIT_ID`.

Details: `git show <COMMIT_ID>` gives you the patch identified by COMMIT_ID. Appending ` -- somefile` narrows that patch down to only include the specified path.

The `-R` option to `git apply` tells it to apply the patch in reverse.

Thus, "undo the changes in `somefile` from this commit".