"Git"의 두 판 사이의 차이
잔글 |
잔글 |
||
359번째 줄: | 359번째 줄: | ||
*[http://code.google.com/p/msysgit/ http://code.google.com/p/msysgit/] | *[http://code.google.com/p/msysgit/ http://code.google.com/p/msysgit/] | ||
*[http://unikys.tistory.com/323 http://unikys.tistory.com/323] | *[http://unikys.tistory.com/323 http://unikys.tistory.com/323] | ||
− | *[http://blog.beany.co.kr/archives/3407 http://blog.beany.co.kr/archives/3407] | + | *[http://blog.beany.co.kr/archives/3407 http://blog.beany.co.kr/archives/3407] |
+ | *[http://d2.naver.com/helloworld/6033708 Gerrit을 이용한 코드 리뷰 시스템 - 코드 리뷰와 Gerrit] | ||
+ | *[http://d2.naver.com/helloworld/1859580 Gerrit을 이용한 코드 리뷰 시스템 - Gerrit과 Git] | ||
+ | *[http://d2.naver.com/helloworld/1859580 [http://d2.naver.com/helloworld/6236097 Gerrit을 이용한 코드 리뷰 시스템 - 코드 리뷰 시스템 설치]] | ||
+ | *[http://d2.naver.com/helloworld/1577518 Gerrit을 이용한 코드 리뷰 시스템 - 인증 환경 설정] | ||
+ | *[http://d2.naver.com/helloworld/1419134 Gerrit을 이용한 코드 리뷰 시스템 - 사용자 권한 관리(1)] | ||
+ | *[http://d2.naver.com/helloworld/1689463 Gerrit을 이용한 코드 리뷰 시스템 - 사용자 권한 관리(2)] | ||
+ | *[http://d2.naver.com/helloworld/2930540 Gerrit을 이용한 코드 리뷰 시스템 - 사용자 환경 설정] | ||
[[Category:오픈소스|Category:오픈소스]]<br/>[[Category:Repository|Category:Repository]]<br/>[[Category:DevOps|Category:DevOps]] | [[Category:오픈소스|Category:오픈소스]]<br/>[[Category:Repository|Category:Repository]]<br/>[[Category:DevOps|Category:DevOps]] |
2018년 1월 3일 (수) 10:27 판
오픈소스 분산 버전 컨트롤 시스템인 git를 정리 한다.
- 홈페이지 : http://git-scm.com/
- 다운로드 : http://git-scm.com/download
- 라이선스 :
- 플랫폼 :
목차
Git 개요
Git은 로컬 저장소를 가지며 SnapShot 형태로 버전을 관리 합니다.
Git 저장소
- Work Space : 개인별 작업 공간
- Staging Area (index) : Commit할 파일을 지정 (git add)
- 로컬 저장소 : 자신이 작업한 내용을 반영 (git commit, git commit -a)
- nonbare-repository : 프로젝트 리소스 저장
- 원격 저장소 : 다른 사람과 작업을 공유할 때 사용 (git push / git pull (git fetch, git merge))
- bare-repository : 이력, 변경 사항 저장
- Work Space -> Staging Area (index) -> Local Storage -> Remote Storage
Master and Branch
- Master : 로컬 저장소의 메인 코드 (git checkout master, git merge branch)
- Origian : 초기 리모트 저장소
- Branch : 새로 작업을 위해 생성한 코드 (git branch, git checkout, git checkbout -b)
Git 설치
CentOS에서 git 설치
Git 설치
yum install git git version |
Git 리모트 저장소 생성
groupadd git #--- Local Repository 생성 #--- Remote Repository 생성 git config --global user.name "Mountain Lover" |
Windows에서 git 설치
Git 설치
Git 다운로드 사이트에서 Windows용 Git 설치 파일(Git-1.9.4-preview20140815.exe)을 다운로드하여 설치 합니다.
P:/001_work/gitRepositor/ 폴더를 만들고 해당 폴더에서 오른쪽 마우스를 클릭 합니다.
Git Bash에서 Git 로컬 저장소 생성
git config --global user.name "Mountain Lover" cd p:/001_work/gitRepository |
Git 테스트
cd p:/001_work/gitRepository/zztemp #--- aaa.xml 파일을 생성 합니다. git status #--- 상태 정보 조회 git add aaa.xml git status git commit git status git push git status |
Git 설정 파일
- /etc/gitconfig : git config -system (시스템별 설정)
- ~/.gitconfig : git config --global (사용자별 설정)
- c:/Users/ghkim/.gitconfig for Windows
- .git/config : git config (저장소별 설정)
참고 문헌
- http://forum.falinux.com/zbxe/index.php?document_srl=588283&mid=lecture_tip
- http://insanehong.kr/post/guide-to-git-for-windows/
Eclipse에 GitHub 설치
Eclipse에서 GitHub를 사용하기 위해 GitHub를 설치 합니다.
"Help -> Install New Software... -> Add.." 메뉴에서 아래 사항을 추가하여 설치 합니다.
- Name : GitHub
- Location : http://www.jgit.org/update-site
Eclipse 환경 설정
"Windows -> Open Perspective" 메뉴에서 "Git"를 추가 합니다. "Clone a Git repository" 링크를 선택하여 리모트 Git repository를 등록 합니다.
Git의 주요 개념
Item | Description |
Branch |
|
Tag |
|
Git 폴더 구조
- .gitignore : Git 관리 대상에서 제외되는 파일 지정 (다른 사람과 공유)
- .git/
- branches/
- hooks/ : 특정 조건을 만족할 경우 실행되는 Hook Script 파일을 관리
- prepare-commit-msg
- pre-commit : Commit 전에 실행
- commit-msg
- pre-push : Push 전에 실행
- update
- post-update
- pre-applypatch
- applypatch-msg
- pre-rebase
- info/
- exclude : Git 관리 대상에서 제외되는 파일 저장 (다른 사람과 공유되지 않음)
- refs : Reference 목록을 저장 (git gc 명령으로 생성)
- logs/
- objects/ : 파일이 BLOB 객체로 저장되는 폴더로 Staging Area에 해당함
- SHA-1 checksum 값의 첫 두자리를 폴더명으로 나머지를 파일 이름으로 사용하여 저장
- 파일 목록을 담은 트리 객체와 commit 정보를 담은 커밋 객체를 저장
- info/ : 메타 데이터
- pack/ : Packfile (Snapshot 저장 방식 대신 변경분 저장 방식으로 하나의 파일로 묶은 파일) 저장
- refs/
- Commit ID 중에서 reference(특정 커밋에 대한 포인터)라는 별도의 이름을 지정한 것을 관리
- heads/ : 최상위 commit 아이디를 저장
- master : Master Branch의 마지막 commit ID 저장
- develop : Develop Branch의 마지막 commit ID 저장
- remotes/origin/ : Remote Git 저장소의 최상위 commit 아이디를 저장
- tags/ : Tag를 저장
- HEAD : HEAD reference가 가리키는 commit ID 저장 (현재 작업 폴더에 check out된 버전을 지정)
- config : 로컬 설정 파일 (이 파일이 있는 Git 저장소에 적용)
- ~/.gitconfig : 사용자 설정 파일 (특정 사용자가 사용하는 모든 Git 저장소에 적용)
- /etc/gitconf : 시스템 설정 파일 (시스템 전체의 모든 Git 저장소에 적용)
파일 이름 : SHA-1로 관리
Commit ID : SHA-1로 관리
Git 명령어
- 저장소 : Work Space -> Staging Area (index) -> Local Storage -> Remote Storage
- 버전 : Master, Branch
분류 | 명령어 | 상세 |
초기 설정 | git init | 현재 폴더를 로컬 저장소 생성 |
git remote add <repository> | 리모트 저장소 연결 Repository : user@password:/~/~
| |
git clone <repository> | 로컬 저장소로 리모트 저장소 복제 | |
저장하기 | git add | Staging Area로 추가 |
git reset HEAD | Staging Area에 추가할 파일을 삭제 | |
git commit | 로컬 저장소로 commit | |
git commit -a | git add + git commit | |
git fetch origin git reset --hard origin/master |
로컬 저장소로 commit한 것을 복구 | |
git push | 리모트 저장소로 commit | |
가져오기 | git fetch | 로컬 저장소로 가져오기 |
git merge | 로컬 저장소의 소스와 병합 | |
git pull | git fetch + get merge | |
버전 관리 | git branch ~ | 브랜치 생성 |
git checkout ~ | ||
git checkout -b ~ | git branch + git checkout | |
git branch -d ~ | 브랜치 삭제 | |
git checkout master | ||
git merge branch | 브랜치 병합 | |
git branch git branch --no-merged git branch --merged |
브랜치 목록 | |
태그 관리 | git tag ~ git tag -a ~ |
태그 생성 |
git tag -d ~ | 태그 삭제 | |
git tag | 태그 목록 | |
설정 관리 | git config --list git config <설정명> |
설정 정보 조회 |
git config [--system | --global] <name> "<value>" | 설정 등록 |
Eclipse에서 git 사용
Eclipse에서 프로젝트 공유
"Team -> Share Project ... -> Git" 메뉴를 선택 합니다.
Git의 Local Repository를 선택하여 공유를 완료 합니다.
Git과 동기화
- Team -> Add to Index : Git으로 관리할 파일로 추가
- Team -> Remote -> Commit : Local Repository로 저장
- Team -> Push : Git Server Repository로 저장
- Source ref로 master를 선택 합니다.
- "Add Spec" 버튼을 선택 합니다.
Hooks
Hook을 사용하여 사용자별 권한 설정을 구현할 수 있습니다.
Client Hooks
pre-commit, prepare-commit-msg, commit-msg / post-commit
applypatch-msg, pre-applypatch / post-applypatch
post-merge
pre-rebase, post-rewrite
pre-push
pre-auto-gc
Server Hooks
pre-receive, update / post-update, post-receive
참고 문헌
- GitHub
- CVS
- Subversion
- https://git-scm.com/book/ko/
- "민짱의 작업실"의 GIT 사용법 (ProGIT)
- http://git-scm.com/downloads : 설치프로그램 다운로드
- http://code.google.com/p/msysgit/
- http://unikys.tistory.com/323
- http://blog.beany.co.kr/archives/3407
- Gerrit을 이용한 코드 리뷰 시스템 - 코드 리뷰와 Gerrit
- Gerrit을 이용한 코드 리뷰 시스템 - Gerrit과 Git
- [http://d2.naver.com/helloworld/6236097 Gerrit을 이용한 코드 리뷰 시스템 - 코드 리뷰 시스템 설치]
- Gerrit을 이용한 코드 리뷰 시스템 - 인증 환경 설정
- Gerrit을 이용한 코드 리뷰 시스템 - 사용자 권한 관리(1)
- Gerrit을 이용한 코드 리뷰 시스템 - 사용자 권한 관리(2)
- Gerrit을 이용한 코드 리뷰 시스템 - 사용자 환경 설정