TOOL/VCS 2015. 8. 24. 18:16

///// GIT (깃) - 형상관리 프로그램




///// Download (다운로드)

http://www.git-scm.com/downloads


///// 추세

CVS -> SVN -> GIT 


///// 개요

[History] - [Stage(Index)] - [Working Directory]

 

HEAD - 현재 작업중인 브랜치의 가장 최근 리비전이라

master - 최근 커밋 (svn의 trunk에 해당)

maint - master브랜치의 루트 커밋

origin - Remoate Repository에서 가져온 브랜치


 

///// 시작

git config --global user.name "이름"

git config --global user.email 이메일

git config --list



git diff A B

git diff --cached 

git diff maint

git diff

git diff HEAD



// git reset

[Stage]를 마지막 커밋 내용으로 갱신

// git reset --hard

[Stage]와 [Working Directory]를 마지막 커밋 내용으로 갱신

// git reset --soft

[Stage]와 [Working Directory]를 갱신하지 않는다. -----> 그럼 왜해???



// git cherry-pick A

// git rebase master

  

 

///// ssh

ssh-keygen -t rsa

 


/////생성

// init

// clone

/////보기

// status

// log

// show

// diff

// branch

/////수정

/////되돌림

// reset

// checkout

// revert

/////업데이트

// pull

// fetch

// merge

// am

/////브랜치

// checkout

/////커밋

// commit

/////퍼블리시

// push

// format-patch

///// 무시하기

// ignore

버전관리가 필요없는 파일을 설정하여 무시하는 기능

.gitignore 파일에 무시할 파일들의 목록이 해당 문법에 맞게 작성됨.

// https://www.gitignore.io/

소스폴더에 포함되어있는 특정도구(IDE)나 언어(Language)의  환경파일 등은 버전관리 항목에서 제외할 필요가 있다.

이 사이트에 들어가서 특정도구나 언어를 검색하면 제외할 항목들을 제공해준다. 

.gitignore파일에 복붙(복사 붙여넣기)하자!

 

 

 

/////////////////////////

///// 예

/////////////////////////

// 사용자 정보 설정

git config --global user.name "cheolsu"

git config --global user.email cheolsu@email.com

// 설정값 확인

git config --list

 

 

 

// git설정되지 않은 디렉토리를 git 저장소(로컬리파지토리)로 만들기

git init

// git 저장소 가져오기

git clone git://gutbub.com/schacon/grit.git

 

 

 

// Working Directory에서 Staging Area로

git add .

// 메세지와 함께 커밋 : Staging Area에서 Local Repository로

git commit -m 'this is first commit with message'

// Working Directory에서 (Staging Area는 생략) Local Repository로

git commit -a -m 'edit some code'

// 최근 커밋의 메세지 편집하기

git commit --amend

VIM편집기가 뜬다( 사용방법 : 

- [ESC] : 일반모드, 입력모드 전환

- 입력모드에서 수정 후

- 일반모드로 전환 후 세미콜론(:) 누르고 w 누르고 q 누르고 엔터

)


 

 

 

//  다른 branch로 이동하기

git checkout branchName

// branch를 만들면서 checkout까지 한번에

git checkout -b newBranchName 

 

 

// 파일의 상태

git status

// branch 확인

git branch

git branch --merged

git branch --no-merged

git branch -v

// branch 지우기

git branch -d branchName

 

 

// 리모트 저장소 확인(로컬리파지토리의 어느 브랜치인지)

git remote

 

git pull

git push origin master

 

// 파일 내용 조회

cat fileName

 

// 태그 조회

git tag

// 커밋 히스토리 조회 (q누르면 빠져나오는 거 같다.)

git log

// 커밋 히스토리 조회 : diff결과와 함께

git log -p

// 커밋 히스토리 조회 : 최근 커밋 3개만 추출

git log -p -3

 

 

 

 

// submodule (자동X, 수동으로 업데이트 해야됨)

git submodule

git submodule status



///// 참고

★ http://marklodato.github.io/visual-git-guide/index-ko.html#conventions

★ http://git-scm.com/book/ko/v1/Git%EB%A7%9E%EC%B6%A4-Git-%EC%84%A4%EC%A0%95%ED%95%98%EA%B8%B0 

★ https://opentutorials.org/course/1492/8135 

http://blog.naver.com/dragmove/30176398721

http://www.slideshare.net/dhrim/git-12030742?related=1
https://try.github.io/levels/1/challenges/4#

http://rogerdudler.github.io/git-guide/index.ko.html

http://gitreal.codeschool.com/levels/1