Git reset to commit hash11/15/2023 We can see that commit is removed from the history but the changes in the staging area and working directory are intact. Git will not allow us to push to the remote repository because of this conflict.Ĭonsider the following example in which we have used the -soft option. This is because the remote repository may still have the commit which we have removed from our local repository. One thing to note is that we should not use the Git Reset command if we intend to push to a remote repository.For example, HEAD~N will reset our head to the Nth commit before our HEAD. We can mention the commit hash of that commit or we can mention its position relative to our HEAD. We can also use the Git Reset command to revert changes to some other commit.But if the commit was a complete failure and you also want to undo the changes of the files involved in that commit then the -hard option is preferred. It will keep the changes in the files and the staging area but will remove the commit. If it is just the commit then -soft is the preferred option.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |