티스토리 뷰

envs/git

Git add commit 취소하기

제이스핀 2020. 3. 22. 16:32
반응형

100mb 이상의 파일을 디렉토리에 둔 채로 add를 하면

에러가 나면서 add를 못하게 되고, 파일을 지우고 다시 add commit 해도 해결되지 않아

취소가 불가피한 상황이 오게 된다.

 

100mb 이상의 파일을 git에 올리기 위해서는 Git LFS를 쓰면 된다.

 

https://nuggy875.tistory.com/76

 

Git LFS를 사용하여 100mb 넘는 파일 git에 업로드하기

최신버전의 git-lfs https://github.com/git-lfs/git-lfs/releases git-lfs/git-lfs Git extension for versioning large files. Contribute to git-lfs/git-lfs development by creating an account on GitHub. g..

nuggy875.tistory.com

 

 

git add 취소

해보고 잘 되었는지 git status 명령어로 확인해보자.

 

- add한 특정 파일을 add 취소

    $ git reset HEAD [파일명]

 

- add한 전체 파일을 add 취소

    $ git reset HEAD

git commit 취소

해보고 잘 되었는지 git log 명령어로 확인해보자.

 

- Commit 취소, commit 했던 파일은 staging area에 있게하고 working directory에 보존하도록
    $ git reset --soft HEAD^

 

- Commit 취소, commit 했던 파일은 unstaged 되고 working directory에 보존하도록 (default)
    $ git reset --mixed HEAD^

 

- Default이므로 --mixed의 설정값을 안 줘도 동일하게 적용
    $ git reset HEAD^

- Commit 취소, commit 했던 파일은 unstaged 되고 working directory에서 삭제하도록 (파일이 지워지니 주의)
    $ git reset --hard HEAD^

 

- 마지막으로 했던 두개의 Commit을 취소

    $ git reset HEAD~2

 

 

반응형

'envs > git' 카테고리의 다른 글

Git LFS를 사용하여 100mb 넘는 파일 git에 업로드하기  (0) 2020.03.22
MacOS 업데이트 시 git 오류  (0) 2019.09.25
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함