"Git"의 두 판 사이의 차이
잔글 |
잔글 (→참고 문헌) |
||
(같은 사용자의 중간 판 32개는 보이지 않습니다) | |||
29번째 줄: | 29번째 줄: | ||
Master and Branch | Master and Branch | ||
− | *Master : 메인 코드 (git checkout master, git merge branch) | + | *Master : 로컬 저장소의 메인 코드 (git checkout master, git merge branch) |
+ | *Origian : 초기 리모트 저장소 | ||
*Branch : 새로 작업을 위해 생성한 코드 (git branch, git checkout, git checkbout -b) | *Branch : 새로 작업을 위해 생성한 코드 (git branch, git checkout, git checkbout -b) | ||
50번째 줄: | 51번째 줄: | ||
|- | |- | ||
| style="background-color: rgb(241, 241, 241);" | | | style="background-color: rgb(241, 241, 241);" | | ||
− | groupadd git<br/>useradd -d /cloudnas/home/git -m -g git git<br/>passwd git | + | groupadd git<br/>useradd -d /cloudnas/home/git -m -g git git<br/>passwd git<br/>su - git |
− | + | #--- Local Repository 생성<br/>mkdir gitLocal<br/>git init | |
+ | |||
+ | #--- Remote Repository 생성<br/>mkdir gitRemote<br/>cd gitRemote<br/>git clone --bare zztemp.git<br/>#--- /cloudnas/home/git/zztemp.git/ 폴더가 생성됨 | ||
git config --global user.name "Mountain Lover"<br/>git config --global user.email "consult@jopenbusiness.com"<br/>git config --list | git config --global user.name "Mountain Lover"<br/>git config --global user.email "consult@jopenbusiness.com"<br/>git config --list | ||
70번째 줄: | 73번째 줄: | ||
− | <span style="font-size:larger;">'''<span style="color:#008000;">Git 로컬 저장소 생성</span>'''</span> | + | <span style="font-size:larger;">'''<span style="color:#008000;">Git Bash에서 Git 로컬 저장소 생성</span>'''</span> |
{| cellspacing="1" cellpadding="1" style="width: 100%;" | {| cellspacing="1" cellpadding="1" style="width: 100%;" | ||
|- | |- | ||
| style="background-color: rgb(241, 241, 241);" | | | style="background-color: rgb(241, 241, 241);" | | ||
− | git clone | + | git config --global user.name "Mountain Lover"<br/>git config --global user.email "consult@jopenbusiness.com"<br/>git config --global push.default simpe #--- 현재 작업중인 branch만 push<br/>git config --list |
+ | |||
+ | cd p:/001_work/gitRepository<br/>git clone [[Ssh:ssh://git@www.jopenbusiness.com/cloudnas/home/git/zztemp.git|ssh://git@www.jopenbusiness.com/cloudnas/home/git/zztemp.git]]<br/>#--- <span style="line-height: 20.7999992370605px; background-color: rgb(241, 241, 241);">p:/001_work/gitRepository/zztemp/.git/ 폴더가 생성됨</span> | ||
+ | |||
+ | |} | ||
+ | |||
+ | |||
− | + | <span style="color:#008000;">'''<span style="font-size:larger;">Git 테스트</span>'''</span> | |
+ | {| cellspacing="1" cellpadding="1" style="width: 100%;" | ||
+ | |- | ||
+ | | style="background-color: rgb(241, 241, 241);" | cd p:/001_work/gitRepository/zztemp<br/><span style="line-height: 20.7999992370605px; background-color: rgb(241, 241, 241);">#--- aaa.xml 파일을 생성 합니다.<br/>git status #--- 상태 정보 조회</span><br/>git add aaa.xml <br/>git status<br/>git commit<br/>git status<br/>git push<br/>git status | ||
|} | |} | ||
96번째 줄: | 108번째 줄: | ||
*[http://forum.falinux.com/zbxe/index.php?document_srl=588283&mid=lecture_tip http://forum.falinux.com/zbxe/index.php?document_srl=588283&mid=lecture_tip] | *[http://forum.falinux.com/zbxe/index.php?document_srl=588283&mid=lecture_tip http://forum.falinux.com/zbxe/index.php?document_srl=588283&mid=lecture_tip] | ||
*[http://insanehong.kr/post/guide-to-git-for-windows/ http://insanehong.kr/post/guide-to-git-for-windows/] | *[http://insanehong.kr/post/guide-to-git-for-windows/ http://insanehong.kr/post/guide-to-git-for-windows/] | ||
+ | |||
+ | |||
+ | |||
+ | === Eclipse에 GitHub 설치 === | ||
+ | |||
+ | [[Eclipse|Eclipse]]에서 [[GitHub|GitHub]]를 사용하기 위해 GitHub를 설치 합니다.<br/>"Help -> Install New Software... -> Add.." 메뉴에서 아래 사항을 추가하여 설치 합니다. | ||
+ | |||
+ | *Name : GitHub | ||
+ | *Location : [http://www.jgit.org/update-site http://www.jgit.org/update-site] | ||
+ | |||
+ | |||
+ | |||
+ | === Eclipse 환경 설정 === | ||
+ | |||
+ | "Windows -> Open Perspective" 메뉴에서 "Git"를 추가 합니다. "Clone a Git repository" 링크를 선택하여 리모트 Git repository를 등록 합니다. | ||
+ | |||
+ | [[File:Eclipse git 001.png|File:Eclipse git 001.png]] | ||
+ | |||
+ | [[File:Eclipse git 002.png|File:Eclipse git 002.png]] | ||
+ | |||
+ | [[File:Eclipse git 003.png|File:Eclipse git 003.png]] | ||
+ | |||
+ | == Git의 주요 개념 == | ||
+ | |||
+ | {| border="1" cellspacing="0" cellpadding="1" style="width:100%;" | ||
+ | |- | ||
+ | | style="text-align: center; background-color: rgb(204, 204, 204);" | Item | ||
+ | | style="text-align: center; background-color: rgb(204, 204, 204);" | Description | ||
+ | |- | ||
+ | | style="text-align: center;" | Branch | ||
+ | | | ||
+ | *master : 최초 생성되는 branch (master -> refs/heads/master) | ||
+ | |||
+ | |- | ||
+ | | style="text-align: center;" | Tag | ||
+ | | | ||
+ | *Branch와 동일한 reference로 reference에 의미를 부여 한다. | ||
+ | *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 명령어 == | == Git 명령어 == | ||
110번째 줄: | 206번째 줄: | ||
| style="text-align: center;" rowspan="3" | 초기 설정 | | style="text-align: center;" rowspan="3" | 초기 설정 | ||
| git init | | git init | ||
− | | 로컬 저장소 생성 | + | | 현재 폴더를 로컬 저장소 생성 |
|- | |- | ||
| git remote add <repository> | | git remote add <repository> | ||
− | | 리모트 저장소 연결<br/>Repository : user@password:/~/~ | + | | 리모트 저장소 연결<br/>Repository : user@password:/~/~ |
+ | *ssh://[user@]host.xz[:port]/path/to/repo.git/ | ||
+ | *[[Git:git://host.xz|git://host.xz]][:port]/path/to/repo.git/ | ||
+ | *http[s]://host.xz[:port]/path/to/repo.git/ | ||
+ | *ftp[s]://host.xz[:port]/path/to/repo.git/ | ||
+ | *rsync://host.xz/path/to/repo.git/ | ||
+ | */path/to/repo.git/ | ||
+ | *file:///path/to/repo.git/ | ||
+ | |||
|- | |- | ||
| git clone <repository> | | git clone <repository> | ||
178번째 줄: | 282번째 줄: | ||
| git tag | | git tag | ||
| 태그 목록 | | 태그 목록 | ||
+ | |- | ||
+ | | style="text-align: center;" rowspan="2" | 설정 관리 | ||
+ | | git config --list<br/>git config <설정명><br/> | ||
+ | | 설정 정보 조회 | ||
+ | |- | ||
+ | | git config [--system | --global] <name> "<value>" | ||
+ | | 설정 등록 | ||
|} | |} | ||
+ | |||
+ | == Eclipse에서 git 사용 == | ||
+ | |||
+ | <span style="font-size:larger;"><span style="color:#008000;">'''Eclipse에서 프로젝트 공유'''</span></span> | ||
+ | |||
+ | "Team -> Share Project ... -> Git" 메뉴를 선택 합니다. | ||
+ | |||
+ | Git의 Local Repository를 선택하여 공유를 완료 합니다. | ||
+ | |||
+ | |||
+ | |||
+ | <span style="font-size:larger;">'''<span style="color:#008000;">Git과 동기화</span>'''</span> | ||
+ | |||
+ | *Team -> Add to Index : Git으로 관리할 파일로 추가 | ||
+ | *Team -> Remote -> Commit : Local Repository로 저장 | ||
+ | *Team -> Push : Git Server Repository로 저장 | ||
+ | **Source ref로 master를 선택 합니다. | ||
+ | **"Add Spec" 버튼을 선택 합니다. | ||
+ | |||
+ | == Hooks == | ||
+ | |||
+ | Hook을 사용하여 사용자별 권한 설정을 구현할 수 있습니다. | ||
+ | |||
+ | <span style="color:#006400;"><span style="font-size:larger;">'''Client Hooks'''</span></span> | ||
+ | |||
+ | pre-commit, prepare-commit-msg, commit-msg / post-commit | ||
+ | |||
+ | applypatch-msg, <span style="line-height: 20.7999992370605px;">pre-applypatch / post-applypatch</span> | ||
+ | |||
+ | post-merge | ||
+ | |||
+ | pre-rebase, post-rewrite | ||
+ | |||
+ | <span style="line-height: 1.6;">pre-push</span> | ||
+ | |||
+ | pre-auto-gc | ||
+ | |||
+ | <span style="color:#008000;"><span style="font-size:larger;">'''Server Hooks'''</span></span> | ||
+ | |||
+ | pre-receive, update / post-update, post-receive | ||
+ | |||
+ | |||
+ | <div><br/></div> | ||
== 참고 문헌 == | == 참고 문헌 == | ||
+ | *[[Gerrit]] | ||
*[[GitHub|GitHub]] | *[[GitHub|GitHub]] | ||
+ | * http://woowabros.github.io/experience/2017/10/30/baemin-mobile-git-branch-strategy.html | ||
*[[CVS|CVS]] | *[[CVS|CVS]] | ||
*[[Subversion|Subversion]] | *[[Subversion|Subversion]] | ||
+ | *[https://git-scm.com/book/ko/ https://git-scm.com/book/ko/] | ||
*"민짱의 작업실"의 GIT 사용법 (ProGIT) | *"민짱의 작업실"의 GIT 사용법 (ProGIT) | ||
203번째 줄: | 360번째 줄: | ||
*[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://d2.naver.com/helloworld/6033708 Gerrit을 이용한 코드 리뷰 시스템 - 코드 리뷰와 Gerrit] | ||
+ | *[http://d2.naver.com/helloworld/1859580 Gerrit을 이용한 코드 리뷰 시스템 - Gerrit과 Git] | ||
+ | *[http://d2.naver.com/helloworld/1859580 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을 이용한 코드 리뷰 시스템 - 사용자 환경 설정]<br/> | ||
[[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년 9월 5일 (수) 18:03 기준 최신판
오픈소스 분산 버전 컨트롤 시스템인 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
참고 문헌
- Gerrit
- GitHub
- http://woowabros.github.io/experience/2017/10/30/baemin-mobile-git-branch-strategy.html
- 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
- Gerrit을 이용한 코드 리뷰 시스템 - 코드 리뷰 시스템 설치
- Gerrit을 이용한 코드 리뷰 시스템 - 인증 환경 설정
- Gerrit을 이용한 코드 리뷰 시스템 - 사용자 권한 관리(1)
- Gerrit을 이용한 코드 리뷰 시스템 - 사용자 권한 관리(2)
- Gerrit을 이용한 코드 리뷰 시스템 - 사용자 환경 설정