I would like to remove a specific commit on a git repository in order to be able to remove a "fix" applied to my software.
There it is an EMC :
#!/bin/bash
rm -rf TEST .git
mkdir TEST
git init
echo "info 1" > TEST/file.txt
git add TEST/
git commit -m "Initial Commit"
echo "info 2" >> TEST/file.txt
git add TEST/
git commit -m "Commit Fix 1 on file"
echo "info 3" >> TEST/file.txt
git add TEST/
git commit -m "Commit Fix 2 sur file"
the result of file.txt will be
info 1
info 2
info 3
And I would like to obtain the file without the line "info 2". The git revert will generate conflict, and I would like to avoid manage those conflicts. That is to say doing like the commit "Commit Fix 1 on file" would have never append.
I tried revert or rebase without any luke, so if you have another idea, I will be glade to have some help.
Sincerely,
To revert a particular commit, you need to identify the hash
of the commit, using git log
, then use git revert <commit>
to create a new commit that removes these changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With