
구글링 하는 시간 절약을 위해 틈틈히 기록합니다.
git init git clone git status git add git commit git push git cherry-pick git rebase git config git revert git stash git clean
브랜치 정보 확인
git branch
git branch -v (마지막 커밋도 확인)
git branch -a (원격 브랜치까지 확인)
브랜치 이동
git checkout <branch-name>
브랜치 생성
git branch <new-branch-name> (현재 브랜치 기준 생성)
git branch <new-branch-name> <parent-branch-name> (분기할 브랜치 지정)
git checkout -b <new-branch-name> (브랜치 생성+이동)
생성한 브랜치 원격 저장소에 Push
git push origin <new-branch-name>
브랜치 삭제
git branch -d <branch-name>
브랜치 강제 삭제
git branch -D <branch-name>
원격 브랜치 삭제
git push origin --delete <branch-name>
원격 저장소 정보 동기화
git fetch -p
강제 푸시
git push -f [origin <branch>]
git push origin +<branch>
대상 브랜치를 현재 브랜치로 머지
git merge <target-branch-name>
git pull origin <target-branch-name> (pull = fetch + merge)
머지 취소
git merge --abort
add (stage) 전 파일 수정 되돌리기
git restore <file>
git checkout -- <file> (구버전)
add 취소
git restore --staged <file>...
git reset <file>
commit 취소
git reset <commit> (commit 이후 취소, 변경파일 유지)
git reset HEAD^ (바로 이전)
commit hard 취소
git reset --hard <commit> (Untracked files 제외하고 commit 이후 변경파일 취소)
머지 되돌리기 커밋 생성
git revert -m <mainline> <commit>
충돌 해결 후 진행
git revert --continue
되돌리기 중단
git revert --abort
한줄로 보기
git log --oneline -10 (-10 최근 10건)
머지만 보기
git log --oneline --merges -10
그래프 보기
git log --oneline --graph -10
계정 변경
git config --system --unset credential.helper
계정 저장
git config --global credential.helper store