I wish to create a git alias that revert a file from a specific commit. e.g. I have the following commits:
aaaaaaaa(HEAD -> DEV-10685) fixup! chore(cloud connector): something c bbbbbbbb chore(grpc): something b cccccccc refactor(agent communicator): something c dddddddd (origin/master, origin/HEAD) fix(config): something d by mistake, I commited a file mistake.txt that I didn't wish into cccccccc refactor(agent communicator): something c along with valid changes.
I wish to create a git alias that of the form: git revert-file mistake.txt cccccccc
to make things easier, I added here two unrelated git aliases, to demonstrate how to use function in git aliases
rhm = reset --hard origin/master coom = ! "f() { git fetch && git co origin/master; }; f" I thought about something like:
- create a fixup that remove the file and rebase and squash it
- do a git rebase, edit the commit, and remove the file and finish the rebase
I didn't find an easy not risky way to do it, any ideas?