How can I revert changes to a file after multiple commits in Git?

I am working on a branch where I have changed file A in multiple commits and now I want to revert all changes from it so that the state of file A is the same as the initial state when it was created when I first created the branch. What's the easiest way to achieve this?

+3


source to share


2 answers


git checkout <sha1_of_commit> file/to/restore

will return the file to the state after <sha1_of_commit>

commit. If you want to revert it to the state before , this commit uses git checkout <sha1_of_commit>~1 file/to/restore

.



+6


source


Install Smart Git - its intuitive GUI software. 10 minutes of reading about it will tell you how it works. Also try google about these commands:

git-reset

git-revert



git-checkout

They work differently depending on what exactly you want.

0


source







All Articles