On Tue, Apr 4, 2023 at 8:37 AM Hongyi Zhao <hongyi.zhao@xxxxxxxxx> wrote: > > On Tue, Apr 4, 2023 at 8:20 AM Hongyi Zhao <hongyi.zhao@xxxxxxxxx> wrote: > > > > On Tue, Apr 4, 2023 at 2:36 AM Phillip Susi <phill@xxxxxxxxxxxx> wrote: > > > > > > > > > Hongyi Zhao <hongyi.zhao@xxxxxxxxx> writes: > > > > > > > Hi here, > > > > > > > > I want to revert a previous commit partially, as follows: > > > > > > > > werner@X10DAi:~$ git log |grep -A3 -B5 -m1 texstudio > > > > commit f18fbd1e16a1ca4215621768d17858c036086608 > > > > Author: Hongyi Zhao <hongyi.zhao@xxxxxxxxx> > > > > Date: Sun Aug 1 20:01:02 2021 +0800 > > > > > > > > deleted: Public/CTAN/IDE/phonon/compile-install-phonon > > > > deleted: Public/CTAN/IDE/texstudio-org/texstudio.git.sh > > > > modified: Public/repo/github.com/Dushistov/sdcv.git.sh > > > > deleted: Public/repo/github.com/goldendict/stardict-relative/bigdict > > > > > > > > More specifically, I just want to revert the following ones: > > > > > > > > deleted: Public/CTAN/IDE/phonon/compile-install-phonon > > > > deleted: Public/CTAN/IDE/texstudio-org/texstudio.git.sh > > > > > > > > Is this possible? > > > > > > If you are comfortable with git-gui and gitk, then I would say just > > > revert it, then click ammend the previous commit in git-gui, and click > > > to unstage the changes you DON'T want to revert, then commit. If you > > > want to do it from the command line, then git-revert, then git checkout > > > HEAD~1 -- ( the other 4 file names here ) will get back the other 4 > > > files then you can git commit --amend. Alternatively you can skip > > > git-revert and instead git checkout f18fbd1e16~1 -- (the two files that > > > you DO want to revert), then git commit. > > > > Thanks for your tips. I've also figured out the similar solution based > > on the comment here [1], as shown below: > > > > $ git show f18fbd1e16a1ca4215621768d17858c036086608 -- > > Public/CTAN/IDE/phonon/compile-install-phonon > > Public/CTAN/IDE/texstudio-org/texstudio.git.sh | git apply --reverse > > --3way > > > > Because the commit I want to revert is done a long time ago, which is > > not the parent of the commit I'm currently on, so I can't use the `~1` > > which indicates that I want to go back one commit from my current > > position. > > Sorry for my inappropriate description above. In fact, it's a more > concise method which also will do the trick, aka, as follows: > > $ git checkout f18fbd1e16~1 -- > Public/CTAN/IDE/phonon/compile-install-phonon > Public/CTAN/IDE/texstudio-org/texstudio.git.sh But I still wonder why the following method doesn't work: werner@X10DAi:~$ git revert f18fbd1e16a1ca4215621768d17858c036086608 --no-commit -- Public/CTAN/IDE/phonon/compile-install-phonon Public/CTAN/IDE/texstudio-org/texstudio.git.sh fatal: bad revision 'Public/CTAN/IDE/phonon/compile-install-phonon' > > [1] https://stackoverflow.com/questions/5669358/can-i-do-a-partial-revert-in-git > > > > Best, > > Zhao