Web/GitHub-VSCode

자주 사용하는 git 명령어 모음

일렁이는코드 2023. 3. 29. 18:35

작업시 사용하는 명령어

# 변경사항 스태시에 올리기 & 커밋 & 푸시
git add . 
git commit -m "커밋메세지"
git push origin 작업 브랜치

# master 브랜치 rebase 하기 (작업 중 마스터,디벨롭 브랜치의 푸시된 변경사항을 작업중 브랜치에 적용할 때)
git rebase -i master

# commit 되돌리기 (변경사항 살아있음)
git reset commit주소 

# commit 되돌리기 (변경사항 삭제)
git reset --hard commit주소

 

Branch

branch 조회

# 로컬, 원격 저장소의 branch 출력
git branch -a 

# 원격 저장소의 branch 출력
git branch -r

 

branch 삭제

# 로컬 브랜치 삭제
git branch -d 브랜치이름

# 원격 브랜치 삭제
git branch origin --delete 브랜치이름

 

원격 저장소

원격 저장소 조회, 끊기 및 연결

# 현재 저장소가 어떤 원격 저장소에 연결되어있는지 조회 (연결되어있지 않으면 반응x,연결되어있으면 아래처럼 출력)
git remote -v 

origin https://github.com/test/test.git (fetch)
origin https://github.com/test/test.git (push)

# 연결된 원격저장소 끊기
git remote remove origin

# 새로운 원격저장소 연결하기
git remote add origin https://github.com/test/test.git

 

 

반응형