Say I have a file that has been added to over time and committed into Git each time. How does one simply revert one of the earlier commits but retain the all the following commits?
For example, a blank file.txt
is added and committed. Each subsequent commit adds an increasing number. I wish to simply undo the first number added (1) but retain the others (2 & 3). It seems like I should use revert
but I'm a little lost.
➜ ls
file.txt
➜ cat file.txt
1
2
3
➜ git log --oneline
afc6136 Add 3
d0cbec0 Add 2
1d6a4ff Add 1
b6c3a92 Init file.txt
➜ git revert 1d6a4ff
error: could not revert 1d6a4ff... Add 1
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
➜ cat file.txt
<<<<<<< HEAD
1
2
3
=======
>>>>>>> parent of 1d6a4ff... Add 1