Re: git revert with partial commit.
- From
- Hongyi Zhao <hongyi.zhao@gmail.com>
- Date
- Apr 4, 2023, 00:28 UTC
- Message-ID
- <CAGP6POLmDtwCnqZN3yBaiYj3VpdpH=bNnKhX6Dfu0NfyVVzYCA@mail.gmail.com>
- In-Reply-To
- <20230402141613.yeseo5fj3lafuf7w@tb-raspi4>
On Sun, Apr 2, 2023 at 10:16 PM Torsten Bögershausen <tboegi@web.de> wrote:
Show 32 quoted lines
> > On Sun, Apr 02, 2023 at 05:17:30PM +0800, Hongyi Zhao wrote: > > 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@gmail.com> > > 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? > > It is. > Find the last commit that had those 2 files, in other word the commit > before f18fbd1e16a1ca4215621, say it is xyz. > > git checkout xyz -- Public/CTAN/IDE/phonon/compile-install-phonon > should get the first file back into your working tree and staged. > > (Of course, this is out of my head. And you should be able to "restore" > both files in one go.)
Thanks a lot for this nice trick, and it works like a charm.
> Good luck.
Best, Zhao