ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • commit, push 취소 / init 취소
    프로그래밍/Git 2020. 12. 23. 16:03

    git commit 취소 명령어는 git reset

    git reset // default option 은 --mixed
    git reset HEAD~ // = git reset --mixed HEAD~
    git reset --mixed HEAD~ // unstaged 상태로 working directory 에 보존
    git reset --soft HEAD~ // staged 상태로 working directory 에 보존
    git reset --hard HEAD~ // unstaged 상태로 working directory 에서 삭제

    현재까지의 commit 목록의 요약본을 확인해볼 수 있는 명령어 git log

    git log --oneline

    git status 명령어 는 현재 commit 된 전체 상태 확인할 수 있다. 마지막 commit 을 기준으로 수정된 파일들(modified)과 새로 만들어진 파일들(untracked)의 목록이 보여진다

    git status

    ~ 은 되돌릴 commit 갯수를 의미한다. 그냥 HEAD~ 하면 바로 이전 commit 1개가 취소된다

    git reset HEAD~
    git reset HEAD~~
    git reset HEAD~2 // 마지막 2개 commit 취소

    전부 되돌린 후, 수정한 commit 내용을 remote 저장소에 덮어쓰고 싶다면 push origin +master 해준다 master X

    git push origin +master

     

    직접 특정 ID 로 되돌릴 때 긴거 쓴다? 232d30e32283a12819fea2d9ced277a2958372fd

     

    * reset HEAD^ 이거 안 먹기도 한다

    git reset asks 'more?' It seems to be filtering out the ^ symbol. as a workaround, use below for now

    git reset --soft HEAD~1

    your shell is interpreting the ^ symbol as a line continuation symbol. either just avoid using ^ .... the ^ is an escape character in the Windows Command Line

     


    - git init 을 입력하면 해당 폴더가 git local 저장소로 설정된다. git local 저장소 폴더에는 숨김파일 형식의 .git 폴더가 만들어지며, 이 폴더에 현재 폴더의 모든 git 정보들이 담긴다

    - git init 을 취소할 때는 .git 폴더를 삭제하면 된다. 그러면 git local 저장소 지정이 해제된다

    rm -r .git

     

    참고

    '프로그래밍 > Git' 카테고리의 다른 글

    Git 최초 연동 / Clone / 권한 주기  (0) 2021.07.17
    Remote 저장소  (0) 2021.04.13
    파일이름 변경 / 대소문자 변경 인식  (0) 2020.12.24
    branch  (0) 2020.12.23
    github pages 배포  (0) 2020.09.30

    댓글