본문 바로가기
Programming/git, svn

[Git] Git(깃) 명령어 완벽 정리 모음 (svn 연동명령 포함)

by 근육곰돌이 2020. 3. 2.
728x90
개발자라면 누구나 사용하는 Git입니다.
하지만 간혹 가다가 생각안나는 명령어가 있어서, 정리해둔 포스팅입니다.

자세한 설명은 제외하고 명령 모음이니 용도에 잘 쓰시길 바랍니다.

 

Git 주로 사용하는 명령어 모음 (git 형상관리)

       
# 명령어 설명 비고
1 git init 저장소 설정  
2 pwd 저장소 확인  
3 git checkout -t 원격저장소브랜치명 원격저장소 브랜치 이름으로 로컬 브랜치 가져오기  
4 git branch branch 확인  
5 git merge branch 병합 git checkout 병합 대상 브랜치git merge 병합 할 브랜치 이름
6 git checkout -b 브랜치명 커밋번호 특정 커밋 번호로 브랜치 git checkout -b v5.7.0.1 011a998
7 git push [원격저장소이름] [로컬브랜치명]   ex) git push origin local_branch
8 git push [원격저장소명] :브랜치명 원격저장소의 브랜치 삭제  
9 git rebase branch 병합(변경된 내용을 순차적으로 적용)  
10 git config --list 설정 확인  
11 git reset --hard 마지막 커밋으로 되돌림  
12 git mergetool branch branch 머지툴 사용  
13 git log --graph --oneline --decorate --date=relative --all 브랜치 그래프 표시  
14 git rm --cached <파일명> unstage 파일  
15 git push origin --delete 브랜치명 리모트 브랜치 삭제  
16 git push -d origin 테그명 리모트 테그 삭제  

 

Git 설정 (git config)

config 세부 옵션 정보: https://musclebear.tistory.com/6

       
# 설정 파일 내용
1 소유권 변경 소스 관리에서 제외 .git/config [core]    filemode = false
2      

 

 

Git 기본 명령어

       
# 명령어 설명 비고
1 git config --global user.name [user name] 작업자 이름 설정  
2 git config --global user.email [user email] 작업자 이메일 설정  
3 git config --global --list 설정값(이름 및 메일 등) 확인  
4 git init git 저장소(repo) 만들기  
5 git remote add [remote name] [remote addres] 별명으로 원격지주소를 저장  
6 git remote rm [remote name] 별명의 원격지를 삭제  
7 git remote rename [remote name] [new name] 별명을 새로운 별명으로 변경  
8 git fetch [remote name] remoet의 모든 정보를 가져옴(모든 branch)  
9 git pull 저장소에서 변경 내용 가져오면서 현재 checkout된 branch에 원격지의 변경 내용을 merge함  
10 git push commit들을 master 저장소에 저장(업데이트)  
11 git push [remote name] [localbranch name] local branch의 내용을 업데이트  
12 git push [server] tag [TAG] server에 tag 전송  
13 git push [server] --tags 변경된 모든 tag 전송  
14 git push [server] [L.B]:[R:B] server 에 local branch 를 -Remote branch이름으로 저장  
15 git tag [TAG NAME] 저장소에 태그를 붙인다.  
16 git tag 태그목록을 본다.  
17 git branch [branch name] 저장소의 branch name으로 branch를 만든다.  
18 git branch branch 목록을 본다.  
19 git branch -a 현재 생성된 모든 local branch와 reomte branch 확인  
20 git checkout [branch name] 다른 브랜치로 전환  
21 git checkout -b [branch name] branch 생성  
22 git checkout [file or folder] git repo 기준 마지막 commit 상태로 돌림  
23 git checkout [id] [file or folder] git repo 기준 id에 해당하는 commit 상태로 돌림  
24 git checkout -f commit 안된 working tree와 -index 수정사항 모두 사라짐  
25 git merge [branch name] branch의 내용을 가져와 합침  
26 git add [file or folder] git에 file 또는 folder 추가  
27 git add * git에 모든 file 또는 folder 추가  
28 git rm [file or folder] git 파일 또는 폴더 제거  
29 git status 현재 git 상태 보기  
30 git commit -m [message] message를 repo에 저장  
31 git diff local과 remote의 차이점을 보여줌  
32 git remote remote서버 확인  

 

Git SVN 연동 명령어

       
# 명령어 설명 비고
1 git svn clone -s [URL] SVN CLONE  
2 git svn info SVN 정보 획득  
3 git svn fetch SVN 동기화  
4 git svn rebase SVN 정보 적용  
5 git svn -r Number:HEAD URL SVN 리비전 커밋  

 

반응형