힘내 재설정
힘내 재설정
reset
저장소를 이전 위치로 되돌리고 commit
그 이후의 변경 사항을 무시할 때 사용하는 명령입니다 commit
.
1단계: 이전 찾기 commit
:
2단계: 저장소를 해당 단계로 다시 이동합니다.
이전 장이 끝나면 우리는 commit
다시 돌아갈 수 있는 역사의 한 부분이 있습니다. 로 시도해 보겠습니다 reset
.
Git 재설정 로그에서 커밋 찾기
먼저 돌아가고 싶은 지점을 찾아야 합니다. 그러기 위해서는 를 거쳐야 합니다
log
.
매우 긴 목록을 피하기 위해 다음 과 같이 표시할 때 마다 한 줄만 제공 log
하는 옵션을 사용할 것
입니다 .--oneline
commit
- 의 처음 7
commit hash
자는 재설정 명령에서 참조해야 하는 것입니다. - 그만큼
commit message
그래서 우리가 원하는 포인트를 찾아봅시다 reset
:
예시
git log --oneline
e56ba1f (HEAD -> master) Revert "Just a regular update, definitely no accidents here..."
52418f7 Just a regular update, definitely no accidents here...
9a9add8 (origin/master) Added .gitignore
81912ba Corrected spelling error
3fdaa5b Merge pull request #1 from w3schools-test/update-readme
836e5bf (origin/update-readme, update-readme) Updated readme for GitHub Branches
daf4f7c (origin/html-skeleton, html-skeleton) Updated index.html with basic meta
facaeae (gh-page/master) Merge branch 'master' of https://github.com/w3schools-test/hello-world
e7de78f Updated index.html. Resized image
5a04b6f Updated README.md with a line about focus
d29d69f Updated README.md with a line about GitHub
e0b6038 merged with hello-world-images after fixing conflicts
1f1584e added new image
dfa79db updated index.html with emergency fix
0312c55 Added image to Hello World
09f4acd Updated index.html with a new line
221ec6e First release of Hello World!
commit
우리는 :
로 돌아가고 싶습니다 . 9a9add8 (origin/master) Added .gitignore
우리가 일을 엉망으로 시작하기 전의 마지막 것입니다.
힘내 재설정
We reset
our repository back to the specific commit using
git reset
commithash
(commithash
being
the first 7 characters of the commit hash we found in the
log
):
Example
git reset 9a9add8
Now let's check the log
again:
Example
git log --oneline
9a9add8 (HEAD -> master, origin/master) Added .gitignore
81912ba Corrected spelling error
3fdaa5b Merge pull request #1 from w3schools-test/update-readme
836e5bf (origin/update-readme, update-readme) Updated readme for GitHub Branches
daf4f7c (origin/html-skeleton, html-skeleton) Updated index.html with basic meta
facaeae (gh-page/master) Merge branch 'master' of https://github.com/w3schools-test/hello-world
e7de78f Updated index.html. Resized image
5a04b6f Updated README.md with a line about focus
d29d69f Updated README.md with a line about GitHub
e0b6038 merged with hello-world-images after fixing conflicts
1f1584e added new image
dfa79db updated index.html with emergency fix
0312c55 Added image to Hello World
09f4acd Updated index.html with a new line
221ec6e First release of Hello World!
Warning: Messing with the commit
history of a repository can be dangerous.
It is usually ok to make these kinds of changes to your own local repository. However, you should avoid making changes that rewrite history to
remote
repositories, especially if others are working with them.
Git Undo Reset
Even though the commits are no longer showing up in the
log
, it is not removed from Git.
If you know the commit hash you can reset
to it:
Example
git reset e56ba1f
Now let's check the log
again:
Example
git log --oneline
e56ba1f (HEAD -> master) Revert "Just a regular update, definitely no accidents here..."
52418f7 Just a regular update, definitely no accidents here...
9a9add8 (origin/master) Added .gitignore
81912ba Corrected spelling error
3fdaa5b Merge pull request #1 from w3schools-test/update-readme
836e5bf (origin/update-readme, update-readme) Updated readme for GitHub Branches
daf4f7c (origin/html-skeleton, html-skeleton) Updated index.html with basic meta
facaeae (gh-page/master) Merge branch 'master' of https://github.com/w3schools-test/hello-world
e7de78f Updated index.html. Resized image
5a04b6f Updated README.md with a line about focus
d29d69f Updated README.md with a line about GitHub
e0b6038 merged with hello-world-images after fixing conflicts
1f1584e added new image
dfa79db updated index.html with emergency fix
0312c55 Added image to Hello World
09f4acd Updated index.html with a new line
221ec6e First release of Hello World!