Git (Working tree - Staging Area - Repository)
Local (내 컴퓨터) | Remote (원격) | |||||
Working Directory |
ㅡ git add → ← git reset ㅡ |
Staging Area |
ㅡ git commit → | Repository | ㅡ git push → ← git pull ㅡ |
Repository |
[git add 취소하기]
git reset HEAD (모든 파일 전체 취소)
git reset HEAD <file명> (특정 파일 취소)
git add를 실행하게 되면 Working Directory에서 StagingArea로 가게 되어 넣었던 파일을 빼낼 수 있음
[git commit 취소하기]
git reset HEAD^
commit을 하였으나 빠진 파일이 있을 경우에 사용
+) git commit --amend
commit message를 잘못 적어서 수정이 필요할 때 사용
[git push 취소하기]
git reset HEAD^ → git commit → git push -f (가장 최근 push 취소)
git reset <commit id> → git commit → git push -f (가장 최근 push 취소)
가장 최근의 commit을 취소하여 Working Directory로 돌아간 후, 수정을 하여 commit을 하고 강제로 push를 함
취소를 하여 특정 commit 이후로 돌아가게 되면 그 이후의 commit은 모두 사라지게 되므로 주의
[git reset]
git reset --help : reset 관련 도움말
git reset --soft : 버전만 지우고 작업한 내용을 살려두기 (add는 한 상태, Working Directory가 비워지지 않음)
git reset --hard : 작업한 내용을 지우고 이전 버전으로 되돌아 감 (add도 하지 않은 상태, Working Directory가 비워짐)
'GIT' 카테고리의 다른 글
[GIT] remote에 push 했을 때, commit 메시지 변경 (0) | 2022.01.20 |
---|---|
[GIT] github.com - Pull request (0) | 2021.08.18 |
[GIT] Cherry-pick & Rebase (0) | 2021.08.18 |
[GIT] 협업 (0) | 2021.08.18 |
[GIT] 백업 (Backup) (0) | 2021.08.18 |
Git (Working tree - Staging Area - Repository)
Local (내 컴퓨터) | Remote (원격) | |||||
Working Directory |
ㅡ git add → ← git reset ㅡ |
Staging Area |
ㅡ git commit → | Repository | ㅡ git push → ← git pull ㅡ |
Repository |
[git add 취소하기]
git reset HEAD (모든 파일 전체 취소)
git reset HEAD <file명> (특정 파일 취소)
git add를 실행하게 되면 Working Directory에서 StagingArea로 가게 되어 넣었던 파일을 빼낼 수 있음
[git commit 취소하기]
git reset HEAD^
commit을 하였으나 빠진 파일이 있을 경우에 사용
+) git commit --amend
commit message를 잘못 적어서 수정이 필요할 때 사용
[git push 취소하기]
git reset HEAD^ → git commit → git push -f (가장 최근 push 취소)
git reset <commit id> → git commit → git push -f (가장 최근 push 취소)
가장 최근의 commit을 취소하여 Working Directory로 돌아간 후, 수정을 하여 commit을 하고 강제로 push를 함
취소를 하여 특정 commit 이후로 돌아가게 되면 그 이후의 commit은 모두 사라지게 되므로 주의
[git reset]
git reset --help : reset 관련 도움말
git reset --soft : 버전만 지우고 작업한 내용을 살려두기 (add는 한 상태, Working Directory가 비워지지 않음)
git reset --hard : 작업한 내용을 지우고 이전 버전으로 되돌아 감 (add도 하지 않은 상태, Working Directory가 비워짐)
'GIT' 카테고리의 다른 글
[GIT] remote에 push 했을 때, commit 메시지 변경 (0) | 2022.01.20 |
---|---|
[GIT] github.com - Pull request (0) | 2021.08.18 |
[GIT] Cherry-pick & Rebase (0) | 2021.08.18 |
[GIT] 협업 (0) | 2021.08.18 |
[GIT] 백업 (Backup) (0) | 2021.08.18 |