Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
public:computer:git [2021/08/23 15:50] – alex | public:computer:git [2022/08/26 15:05] (current) – [Git 사용법 정리] alex | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Using git ====== | ====== Using git ====== | ||
+ | |||
+ | |||
+ | ^ git 자주 사용하는 명령어 모음 | ||
+ | ^ 깃 초기화 | ||
+ | ^ 깃 상태 확인 | ||
+ | ^ 깃 저장소 복제 | ||
+ | ^ 파일 등록과 커밋 | ||
+ | ^ ::: | git commit -a -> 에디터에서 커밋 메시지 작성 | ||
+ | ^ ::: | git commit -am " | ||
+ | ^ 로그 확인 | ||
+ | ^ 커밋 비교 | ||
+ | ^ 원격 저장소 별칭 확인 | ||
+ | ^ 원격 저장소 별칭과 URL 확인 | ||
+ | ^ 원격 저장소와 연결 | ||
+ | ^ 원격 서버 삭제 | ||
+ | ^ 커밋 가져오기 | ||
+ | ^ 커밋 전송하기 | ||
+ | ^ 현재 브랜치 확인 | ||
+ | ^ 브랜치 생성 | ||
+ | ^ 브랜치 이동 | ||
+ | ^ 스태시 저장 | ||
+ | ^ 스태시 읽기 | ||
+ | ^ 브랜치 병합 | ||
+ | ^ 리베이스 병합 | ||
+ | ^ 리셋 | ||
+ | ^ 리버트 취소 커밋 | ||
+ | ^ 태그 관리 | ||
+ | ^ 태그 전송 | ||
+ | ^ 서브모듈로 연결 | ||
+ | |||
===== why git? ===== | ===== why git? ===== | ||
Line 55: | Line 85: | ||
* revert; 기존 커밋을 남겨 두고 취소에 대한 새로운 커밋 생성. | * revert; 기존 커밋을 남겨 두고 취소에 대한 새로운 커밋 생성. | ||
* reset vs. revert; 커밋 정보의 삭제 여부. 리셋: 커밋 삭제, 리버트: 취소 커밋 생성 | * reset vs. revert; 커밋 정보의 삭제 여부. 리셋: 커밋 삭제, 리버트: 취소 커밋 생성 | ||
+ | * versioning; major.minor.patch, | ||
+ | * RC(Release Candidate), GA(General Availability), | ||
+ | * tag; 특정 커밋에 태그 부착 | ||
+ | * Annotated; 태그 이름 + 정보 포함 | ||
+ | * Lightweight; | ||
+ | * ./ | ||
<cli prompt=" | <cli prompt=" | ||
Line 150: | Line 186: | ||
$ git revert --mainline 숫자 병함커밋ID | $ git revert --mainline 숫자 병함커밋ID | ||
+ | $ git tag | ||
+ | $ git tag -l # 또는 --list | ||
+ | |||
+ | $ git tag -a 버전 | ||
+ | |||
+ | $ git log --decorate | ||
+ | |||
+ | $ git tag -a 버전 -m " | ||
+ | |||
+ | $ git tag -d 태그이름 | ||
+ | |||
+ | $ git show 태그이름 | ||
+ | |||
+ | $ git tag 태그이름 | ||
+ | |||
+ | $ git tag -a 태그버전 커밋ID | ||
+ | |||
+ | $ git checkout 태그버전 | ||
+ | $ git checkout -b 브랜치이름 태그이름 | ||
+ | |||
+ | $ git push 태그이름 | ||
+ | $ git push 원격저장소이름 --tags | ||
+ | $ git push --delete 원격저장소이름 태그이름 | ||
+ | $ git push 원격저장소이름 로컬태그이름: | ||
Line 273: | Line 333: | ||
* 하나의 프로젝트 여러 명의 개발자 | * 하나의 프로젝트 여러 명의 개발자 | ||
* develop 브랜치에서 각 개발자별로 브랜치 생성후 작업 (보통 기능별로 개발자에게 분배) 혹은 develop에서 기능별 브랜치 생성 | * develop 브랜치에서 각 개발자별로 브랜치 생성후 작업 (보통 기능별로 개발자에게 분배) 혹은 develop에서 기능별 브랜치 생성 | ||
+ | * git-flow, github-flow, | ||
===== submodule ===== | ===== submodule ===== | ||
+ | * 저장소를 모듈화, 저장소 분리 | ||
+ | * 저장소 하나가 다른 깃 저장소를 포함하는 형태 | ||
+ | * 메인 저장소 <-> 부 저장소 | ||
+ | * 2개 이상인 저장소를 부모/ | ||
+ | * 서버 저장소를 서브폴더 형태로 취급 | ||
+ | * .gitmodules | ||
+ | * 메인에서 서브저장소 추가 -> .gitmodules 추가 -> 커밋 | ||
+ | * 저장소마다 별도로 커밋 수행 | ||
+ | * 메인 저장소는 서브모듈의 변경 내용을 모니터링, | ||
+ | |||
+ | <cli prompt=" | ||
+ | $ git submodule -help | ||
+ | |||
+ | $ git submodule add 원격저장소URL 폴더이름 | ||
+ | $ git add .gitmodules | ||
+ | $ git commit -m "add submodule" | ||
+ | |||
+ | $ git submodule init # 서브모듈 초기화, 하위 저장소의 내용을 가져오기 위해. 메인저장소에서 실행 | ||
+ | $ git submodule update | ||
+ | |||
+ | # submodule 사용시, 아래 두 줄은 세트라고 생각하면 됨. | ||
+ | $ git pull origin master | ||
+ | $ git submodule update | ||
+ | </ | ||
===== fork, pull request ===== | ===== fork, pull request ===== | ||
+ | * PR(Pull Request) @github, MR(Merge Request) @gitlab | ||
* fork -> clone forked repository -> make branch and move to branch on forked repository -> coding jobs on branch -> push -> pull request | * fork -> clone forked repository -> make branch and move to branch on forked repository -> coding jobs on branch -> push -> pull request | ||
+ | |||
+ | ===== Etc ===== | ||
+ | * refs, reflog | ||
+ | * file annotation; blame, | ||
+ | * replace; 기존 커밋을 다른 커밋인 것처럼 변경 | ||
+ | * garbage collect; 연결고리가 없는 고립된 객체들, 주로 리셋/ | ||
+ | * prune | ||
+ | * rerere(reuse recorded resolution); | ||
+ | |||
+ | <cli prompt=" | ||
+ | $ git rev-parse 브랜치이름 | ||
+ | $ git show 해시값 | ||
+ | |||
+ | $ ls .git/refs -all # 저장소 refs 파일 목록 | ||
+ | |||
+ | $ git reflog | ||
+ | |||
+ | $ git blame 파일이름 | ||
+ | $ git blame -L 시작줄, | ||
+ | |||
+ | $ git replace 커밋ID1 커밋ID2 | ||
+ | |||
+ | $ git gc --auto | ||
+ | |||
+ | $ git prune --dry-run --verbose | ||
+ | $ git reflog expire --expire=now | ||
+ | $ git prune --expire now -v # 객체 삭제 실행 | ||
+ | |||
+ | $ git remote prune # 원격 저장소의 브랜치를 병합한 후 삭제, 삭제된 원격 저장소 브랜치는 더이상 참조할 수 없다 | ||
+ | $ git fetch --prune | ||
+ | |||
+ | $ git config rerere.enabled true # rerere 기능 사용, --global 옵션 가능 | ||
+ | $ git rerere status | ||
+ | |||
+ | </ | ||
Line 408: | Line 529: | ||
references | references | ||
</ | </ | ||
- | pro git 한글판 http:// | + | * pro git 한글판 http:// |
- | git 간편안내서 http:// | + | |
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||