Git 문서 원본 보기
←
Git
둘러보기로 가기
검색하러 가기
문서 편집 권한이 없습니다. 다음 이유를 확인해주세요:
요청한 명령은 다음 권한을 가진 사용자에게 제한됩니다:
사용자
.
이 문서는 편집하거나 다른 명령을 할 수 없도록 보호되어 있습니다.
문서의 원본을 보거나 복사할 수 있습니다.
오픈소스 분산 버전 컨트롤 시스템인 git를 정리 한다. *홈페이지 : [http://git-scm.com/ http://git-scm.com/] **매뉴얼 : http://git-scm.com/book/ko *다운로드 : [http://git-scm.com/download 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 설치 === <span style="color:#008000;"><span style="font-size:larger;">'''Git 설치'''</span></span> {| cellspacing="1" cellpadding="1" style="line-height: 20.7999992370605px; width: 695px;" |- | style="background-color: rgb(241, 241, 241);" | yum install git<br/>git version<br/> |} <span style="font-size:larger;">'''<span style="color:#008000;">Git 리모트 저장소 생성</span>'''</span> {| cellspacing="1" cellpadding="1" style="line-height: 20.7999992370605px; width: 695px;" |- | style="background-color: rgb(241, 241, 241);" | 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 |} === Windows에서 git 설치 === <span style="color:#008000;"><span style="font-size:larger;">'''Git 설치'''</span></span> [http://git-scm.com/download/win Git 다운로드 사이트]에서 Windows용 Git 설치 파일(Git-1.9.4-preview20140815.exe)을 다운로드하여 설치 합니다. P:/001_work/gitRepositor/ 폴더를 만들고 해당 폴더에서 오른쪽 마우스를 클릭 합니다. [[File:Git install 001.png|File:Git install 001.png]] <span style="font-size:larger;">'''<span style="color:#008000;">Git Bash에서 Git 로컬 저장소 생성</span>'''</span> {| cellspacing="1" cellpadding="1" style="width: 100%;" |- | style="background-color: rgb(241, 241, 241);" | 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 |} <span style="color:#008000;">'''<span style="font-size:larger;">Git 설정 파일</span>'''</span> */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://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/] === 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 명령어 == *저장소 : Work Space -> Staging Area (index) -> Local Storage -> Remote Storage *버전 : Master, Branch {| border="1" cellspacing="0" cellpadding="2" style="width: 100%;" |- | style="text-align: center; background-color: rgb(241, 241, 241);" | 분류 | style="text-align: center; background-color: rgb(241, 241, 241);" | 명령어 | style="text-align: center; background-color: rgb(241, 241, 241);" | 상세 |- | style="text-align: center;" rowspan="3" | 초기 설정 | git init | 현재 폴더를 로컬 저장소 생성 |- | git remote add <repository> | 리모트 저장소 연결<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> | 로컬 저장소로 리모트 저장소 복제 |- | style="text-align: center;" rowspan="6" | 저장하기 | git add | Staging Area로 추가 |- | git reset HEAD | Staging Area에 추가할 파일을 삭제 |- | git commit | 로컬 저장소로 commit |- | git commit -a | git add + git commit |- | git fetch origin<br/>git reset --hard origin/master<br/> | 로컬 저장소로 commit한 것을 복구 |- | git push | 리모트 저장소로 commit |- | style="text-align: center;" rowspan="3" | 가져오기 | git fetch | 로컬 저장소로 가져오기 |- | git merge | 로컬 저장소의 소스와 병합 |- | git pull | git fetch + get merge |- | style="text-align: center;" rowspan="7" | 버전 관리 | git branch ~ | 브랜치 생성 |- | git checkout ~ | <br/> |- | git checkout -b ~ | git branch + git checkout |- | git branch -d ~ | 브랜치 삭제 |- | git checkout master | <br/> |- | git merge branch | 브랜치 병합 |- | git branch<br/>git branch --no-merged<br/>git branch --merged<br/> | 브랜치 목록 |- | style="text-align: center;" rowspan="3" | 태그 관리 | git tag ~<br/>git tag -a ~<br/> | 태그 생성 |- | git tag -d ~ | 태그 삭제 |- | 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]] * http://woowabros.github.io/experience/2017/10/30/baemin-mobile-git-branch-strategy.html *[[CVS|CVS]] *[[Subversion|Subversion]] *[https://git-scm.com/book/ko/ https://git-scm.com/book/ko/] *"민짱의 작업실"의 GIT 사용법 (ProGIT) :*[http://blog.daum.net/_blog/BlogTypeView.do?blogid=0PhZr&articleno=72&categoryId=5®dt=20101210195132 1.1. 버전 관리 시스템의 개념] :*[http://blog.daum.net/_blog/BlogTypeView.do?blogid=0PhZr&articleno=73&categoryId=5®dt=20101210195230 1.2. GIT 개발 역사 / 1.3. GIT 기본 개념] :*[http://blog.daum.net/_blog/BlogTypeView.do?blogid=0PhZr&articleno=74&categoryId=5®dt=20101210195309 1.4. GIT 설치] :*[http://blog.daum.net/_blog/BlogTypeView.do?blogid=0PhZr&articleno=75&categoryId=5®dt=20101210195342 1.5. 최초 GIT의 환경 설정] :*[http://blog.daum.net/_blog/BlogTypeView.do?blogid=0PhZr&articleno=76&categoryId=5®dt=20101210195419 2.1. GIT 저장소(Repository)의 취득] :*[http://blog.daum.net/_blog/BlogTypeView.do?blogid=0PhZr&articleno=77&categoryId=5®dt=20101210195510 2.2. GIT 저장소(Repository)에 기록] :*[http://blog.daum.net/_blog/BlogTypeView.do?blogid=0PhZr&articleno=78&categoryId=5®dt=20101210195545 2.3. 위탁 이력의 열람] :*[http://blog.daum.net/_blog/BlogTypeView.do?blogid=0PhZr&articleno=79&categoryId=5®dt=20101210195623 2.4. 작업의 재시도] :*[http://blog.daum.net/_blog/BlogTypeView.do?blogid=0PhZr&articleno=80&categoryId=5®dt=20101210195716 2.5. 원격 저장소의 사용 방법] :*[http://blog.daum.net/_blog/BlogTypeView.do?blogid=0PhZr&articleno=81&categoryId=5®dt=20101210195824 2.6. 태그(TAGS) 붙이기] *[https://help.github.com/articles/set-up-git https://help.github.com/articles/set-up-git] :*[http://git-scm.com/downloads http://git-scm.com/downloads] : 설치프로그램 다운로드 *[http://code.google.com/p/msysgit/ http://code.google.com/p/msysgit/] *[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]]
Git
문서로 돌아갑니다.
둘러보기 메뉴
개인 도구
로그인
이름공간
문서
토론
변수
보기
읽기
원본 보기
역사 보기
더 보기
검색
주요 메뉴
오픈소스 컨설팅
오픈소스
오픈소스 라이선스
오픈소스 커뮤니티
오픈소스 종류
오픈소스 현황
오픈소스 한글화
문자셋과 인코딩
Storage
Network
보안
고가용성
모니터링
오픈 API
오픈 서비스
Cloud
BigData
Android
산사랑 노트
둘러보기
인기 문서
최근 수정 문서
모든 문서
모든 분류
임의 문서
위키 사용법
자매 사이트
CMS
오비컨 홈페이지
오비컨 CMS
블로그
데모 - SuiteCRM
산사랑의 Twitter
산사랑의 Facebook
친구 사이트
공개SW 포털
OLIS
한국공개소프트웨어협회
AppCenter 지원본부
OLC
PSEG
개발자 블로그
블로터
개인 메뉴
메뉴 수정
양식함
도구
여기를 가리키는 문서
가리키는 글의 최근 바뀜
특수 문서 목록
문서 정보