[Git] 유용한 Git 명령어 모음

hahaha·2021년 8월 1일
0

Git

목록 보기
3/5
post-thumbnail

commit 수정하기

$ git commit --amend	//가장 최근 커밋 수정
  • 커밋 수정 후, ESC + :wq! 로 반영하기)

커밋 이력 확인하기

$ git log		// commit Hash, Author, Date 확인 가능
$ git log -1		// 최근 한 개 커밋
$ git log --oneline	// 간략한 로그 확인

$ git reflog 		// 이전 수행 목록

상태 확인하기

$ git status

현재 브랜치 최신화 하기

$ git fetch --all			// 변경사항 가져오기
$ git status				// 현재 상태 확인 
$ git reset origin/develop(타겟 브랜치)	// origin/devleop 으로 재설정
  • 최신화가 필요한 경우, shell에 뜨는 경고
    Your branch is behind 'origin/develop' by 3 commits, and can be fast-forwarded. (use "git pull" to update your local branch)

브랜치 상태 되돌리기

$ git reset origin/develop(타겟 브랜치) --hard

merge 할 때, conflict가 발생한 경우

$ git rebase origin/develop(타겟 브랜치)
  • conflict가 발생한 경우,
    IDE(JetBrains 경우)에서 ⇧ (shift) 더블 클릭 > resolve conflict -> 충돌 코드 해결(현재 - 병합 결과 - 타겟 대상) -> apply
$ git add .		// 모든 변경 사항 스테이징 영역으로 이동
$ git rebase --continue	// rebase 계속 진행

Cherry Pick

git reset origin/develop --hard
git cherry-pick [commit id]	// 유지하고 싶은 커밋 번호
git add .
git cherry-pick --continue

원격 브랜치를 로컬 브랜치로 가져오기

$ git checkout -t origin/feat/PC-000(원격 브랜치명)

브랜치명 변경하기

$ git branch -m 변경전브랜치명 변경할브랜치명
profile
junior backend-developer 👶💻

0개의 댓글