I have modified my source directory by deleting certain files and done a commit. And I did a push origin master to remote host, github.
Now I came to know that I need those files for proper functioning. Now I need a way to go back my prev commit and then push to my remote host.
Is it possible to do so? I’m very new to git, I’m confused with it.
Thanks in advance.
git revertcreates a new commit that undoes one or more previous commits. This is usually the best way to undo commits that have already been pushed.For example, this command would revert everything from the commit
abc1234up to and including the latest commit (HEAD):You could also use
git reset, but this command changes history and would cause problems for anyone else who is using the repository. In general you should only use this command if you want to discard changes that haven’t been pushed (and that you’re sure you won’t want to come back to in future).