GIT study.
잘 정리된 site….
http://www.dreamy.pe.kr/zbxe/95408
http://blog.outsider.ne.kr/572
http://wangsy.com/blog/wp-content/uploads/2011/11/Git-Guide-r1.pdf
http://rogerdudler.github.com/git-guide/index.ko.html
http://dogfeet.github.com/articles/2012/progit.html
http://www.dreamy.pe.kr/zbxe/CodeClip/95408
http://git-scm.com/ « 간단히 배우는 내용도 있다.
- Git 관련 기본 다운로드 및 설정 관련.
linux에 설치
apt-get install git-core
윈도우에 설치.
http://code.google.com/p/msysgit 받아서 설치.
명령어들.
git config –global [actioin]
사용자정보 입력
git config –global user.name “xxxx xxx”
git config –global user.email xxxx.xxx@google.com
설정확인
git config –list
도움말 보기
git help
git help [action]
git [action] –help
man git-[action]
Git 관련 문의
irc.freenode.net
- Git 사용법.
2-1 현재 자신의 Code로 프로젝트 만들기.
프로젝트 디렉토리로 이동.
git init
(.git이라는 하위 디렉토리를 만든다.)
git add *.c
git add README
git commit -m ‘initial project version’
2-2 서버에 있는 프로젝트 가져오기 (clone)
git clone git://github.com/schacon/grit.git
- grit 라는 폴더에 프로젝트를 가져오고 .git을 만든다.
git clone git://github.com/schacon/grit.git mygrit
- mygrit라는 폴더에 프로젝트를 가져오고 .git을 만든다.
clone한 프로젝트의 file 상태확인하기
git status (수정된 상태도 모두 표시)
수정된 내용 확인
git diff (좀더 확인이 필요할듯.. 어렵네..)
staged 상태에 있는 파일을 이전버젼(commit된파일)과 비교 : git diff –cached
staged 상태로 넣은것과 이후에 수정한 버젼 비교 : git diff
수정한 파일 add하기
git add xxx.c (xxx.c를 staged 상태로 바꿈. staged상태는 commit하기전 상태임)
git add 만 쓰면 하위 폴더 수정된 내용들을 모두 추적하지만 staged 상태로 바꾸지는 않는다.
무시해야 하는 파일 처리 (.o 등)
cat .gitignore
*.[oa]
*~
변경사항 commit 하기 (반영하기)
git add로 추가된 파일만 처리한다.
git status로 확인시 staged인것만 처리한다.
git commit
commit 한 내용을 좀더 자세히 알기 위해 comment를 넣을수 있다.
git commit -m “첫 작업……”
파일 삭제하기
git rm (삭제하고 staged 상태로 바꾸기)
git commit
파일 이름 바꾸기
git mv file_from file_to
git commit
히스토리 보기
git log
ex>git log -p -2 최근 두개의 commint한 값들의 diff 결과를 보여준다.
git log –stat 각 커밋의 통계 정보를 조회
git log –pretty=format:”%h -%ah, %ar : %s” 특정 형식으로 보여줄수도 있다.
git log –graph
되돌리기(undo)
반영하기 않고 되돌리기는 되나 한번 되돌리면 복구기 안된다.
- 커밋 수정하기
git commit –amend
ex ) commit하고 파일을 추가하고 싶을때 아래와 같이 두번째 라인의 add를 하고 다시 commit –amend하면된다.
git commit -m ‘initial commit’
git add forgotten_file
git commit –amend
-staged 상태를 unstage 상태로 돌리기
git reset HEAD xxx.c
-Modified 상태로 되돌리기
git checkout – [filename]
리모트 저장소 사용하기 [다른사람과 같이 작업하는 서버로 생가하면된다.]
- 저장소 확인하기
git remote (보통 origin으로 저장되어 보여준다.)
git remote -v (자세히 보기 위해서 사용된다.)
- 리모트 저장소 추가하기
git remote add [name] [url]
- 리모트 저장소 데이터 땡기기
git fetch [remote-name]
ex) git fetch origin (자동으로 머지해주지 않는다.)
git pull [remote-name] clone한 서버에서 가져와서 자동으로 머지도 해준다..
-리모트 서버에 반영하기
git push origin master
-리모트 저장소 살펴보기
git remote show origin
Git branch———————–
git branch :현재 branch를 보여준다.
git branch -v :마지막 commit 자료를 보여줌.
처음 clone 상태로 복귀하는 방법.
git reset HEAD –hard
git editor 바꾸고 싶을때..
#git config –global core.editor “vim”
\