-
How to backtrack in GitGit 2021. 10. 18. 13:59
Git에서 수정사항을 되돌리는 방법에 대한 정리글입니다.
< head commit >
To see the most recently made commit.
- The Commit you are currently on is the HEAD commit.(in many case, the most recently made commit)
ex)
$ git show HEAD commit cc09c926c4db753354b5b66755dfaa25fecfbca8 Author: codecademy <ccuser@codecademy.com> Date: Mon Oct 18 02:44:16 2021 +0000 Complete the ghosts line diff --git a/scene-5.txt b/scene-5.txt index b12dd97..5dd5d4e 100644 --- a/scene-5.txt +++ b/scene-5.txt @@ -12,3 +12,7 @@ Hamlet: I will. +Ghost: +My hour is almost come, +When I to sulphurous and tormenting flames +Must render up myself. \ No newline at end of file
< git checkout >
To restore the file in your working directory to look exactly as it did when you last made a commit.
$ git checkout HEAD <filename>
< git reset 1 >
To unstage the file from the staging area.
$ git reset HEAD <filename>
- It does not discard the file changes from the working directory, it just removes them from the staging area.
+. If we want to go back by undoing the commit history
$ git reset HEAD^ $ git reset HEAD^1 $ git reset HEAD~1
< git reset 2 >
To Resets the HEAD to a previous commit in your commit history.
$ git reset <commit_SHA>
- This command works by using the first 7 characters of the SHA of a previous commit. For example,
if the SHA of the previous commit is 5d692065cf51a2f50ea8e7b19b5a7ae512f633ba, use :
$ git reset 5d69206
'Git' 카테고리의 다른 글
Introduction to Git (0) 2021.10.18 Git Workflow (0) 2021.10.18