* bd6903f first commit Undoing hard reset to HEAD * 7a9ad7f (HEAD -> feature, origin/master, master) version 2 commit $ git reset -hard HEAD^Īs you can see, the HEAD of the release branch is now pointing to the second commit : we essentially have reset to the commit before HEAD. In order to hard reset to the commit right before HEAD, use “git reset” with the “–hard” option and specify HEAD^. * 7a9ad7f (origin/master, master) version 2 commitĪs you can see in the example, the “feature” branch is one commit ahead of the HEAD of the master branch. * 802a2ab (HEAD -> feature, origin/feature) feature commit Using the “git log” command, you will be able to have a global understanding of your current Git branch and its commits. When trying to reset files, the first command that you want to launch is the “ git log” command. In order to understand the “hard reset” use cases, let’s have some quick examples. Using “–hard”, you will be left with the untracked files of your working directory. The “–hard” option is used in order to reset the files of the index (or the staging area) and of the working directory. The purpose of the “git reset” command is to move the current HEAD to the commit specified (in this case, the HEAD itself, one commit before HEAD and so on). $ git reset -hard HEAD~2 (going back two commits before HEAD) $ git reset -hard HEAD~1 (equivalent to "^") $ git reset -hard HEAD^ (going back to the commit before HEAD) $ git reset -hard HEAD (going back to HEAD) To hard reset files to HEAD on Git, use the “git reset” command with the “–hard” option and specify the HEAD. In this section, we are going to describe how you can hard reset files on Git. When resetting files on Git, you essentially have two options : you can either hard reset files or soft reset files.
0 Comments
Leave a Reply. |