레이블이 git인 게시물을 표시합니다. 모든 게시물 표시
레이블이 git인 게시물을 표시합니다. 모든 게시물 표시

2013년 5월 21일 화요일

git 공부하는 법


아래 2개의 링크만 봐도 git의 기본적인 동작을 알고 사용하는데 무리가 없다라고 판단됩니다. 당연히  실제 사용해본다면 더 이해하고, 효율적으로 사용하는데 도움이 될 것 입니다.

2013년 4월 10일 수요일

git tag 사용하기

* Tag 조회하기
$git tag

* Tag 조회하기(message와 함께)
$ git tag --list -n

* Tag 붙이기
$git tag -a %VERSION_NUMBER% -m '%MESSAGE%'

* 나중에 Tag 붙이기
$ git tag -a %VERSION_NUMBER% %COMMIT_HASH%

* 특정 Tag 공유하기
$git push origin %TAG_NAME%

* 전체 Tag 공유하기
$git push origin --tags

* 로컬의 Tag 제거하기
$ git tag -d %TAG_NAME%

* 원격의 Tag 제거하기
$git push origin :%TAG_NAME%
or
$git push --delete origin %TAG_NAME%


2013년 3월 31일 일요일

git stash 사용하기(just save with no commit to change branch)

stash미국∙영국 [stӕʃ]

동사


[타동사][VN + adv. / prep.] (비격식) (안전한 곳에) 넣어 두다[숨기다]

작업 중이던 파일들을 commit하지 않고, branch를 변경해서 작업하고자 할 경우에 기존 작업들을 안전한 곳(git stack)에 넣어두기 위한 명령어이다.

* branch변경 시, 작업중인 파일들을 commit하지 않고 안전하게 보관하기
$git stash

* stash한 파일(들) 확인하기
$git stash list

* stash한 파일(들) 복원하기(<-- staged상태까지는 복원되지 않는다.)
$git stash apply

* stash한 파일(들) 복원하기(<-- staged상태까지 복원한다.)
$git stash apply --index

위의 apply옵션은 단순히 stash를 적용만 할 분이다. 즉, apply옵션을 사용하여 stash하게 되면,  stash된 파일(들)이 여전히 git stack에 저장되어 있다. 

* stash한 파일(들) stack에서 제거하기
$git stash drop %STASH_NUM%

* stash한 파일(들)을 적용과 동시에 stack에서 제거하기
 $git stash pop

* stash할 당시의 커밋을 checkout 한 후 새로운 브랜치를 만들고 여기에 적용하기
$ git stash branch %NEW_BRANCH_NAME%

2013년 3월 26일 화요일

git history 조회하기

* git history 조회하기
$git log

* 각 commit의 diff결과와 함께 제한된 개수의 git history 조회하기
$git log -p -%LOG_COUNT_INTEGER%

* 각 commit의 통계 정보(commit정보와 +/-량을 표시)를 포함한 git history 조회하기
$git log --stat

* 각 commit을 1라인으로 표시하는 방식으로 graph정보를 포함한 git history 조회하기
$git log --oneline --graph

git branch 사용하기

* branch를 만들면서 checkout하기
$git checkout -b %BRANCH_NAME%


* branch 삭제하기
$git branch -d %BRANCH_NAME%
예제) tnkim@tnkim-N53SV:~/git/hugomachlink$ git branch -d add_cmd_inputgps_git207 
          Deleted branch add_cmd_inputgps_git207 (was c05836e).


* branch 목록보기
$git branch
예제) tnkim@tnkim-N53SV:~/git/hugomachlink$ git branch
                add_cmd_inputgps_git207
               * master


* 마지막 커밋메시지와 함께 branch 목록보기
$git branch -v
예제) tnkim@tnkim-N53SV:~/git/hugomachlink$ git branch -v
               add_cmd_inputgps_git207 c05836e add input gps function and caller
              * master                  c94a1bb trivial: 예외처리 코드 추가 및 코드 정리


* merged branch 목록보기 (<-- merged branch라면 삭제대상이 되는 branch이다.)
$git branch --merged
예제) tnkim@tnkim-N53SV:~/git/hugomachlink$ git branch --merged
        add_cmd_inputgps_git207
       * master


* no-merged branch 목록보기(<-- no-merged branch라면 merge되어야 하는 대상이 되는 branch로서 삭제하면 안된다.)
$git branch --no-merged


* branch 공유하기
$git push (remote) (branch)
예제) tnkim@tnkim-N53SV:~/git/fx500machlink$ git push origin fx500machlink_with_standardtimeout 
Counting objects: 13, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (7/7), 585 bytes, done.
Total 7 (delta 3), reused 0 (delta 0)
To gitolite@sf.thinkware.co.kr:tnkim/fx500machlink.git
 * [new branch]      fx500machlink_with_standardtimeout -> fx500machlink_with_standardtimeout


* 공유된 branch에 코드 push하기
master branch에서와 동일하다.
local에 있는 branch한 뒤에 git push하면 해당 remote branch로 코드 push된다.


tnkim@tnkim-N53SV:~/git/fx500machlink$ git commit -m 'trivial: 불필요한 코드제거'
[fx500machlink_with_standardtimeout 8f44b60] trivial: 불필요한 코드제거
 1 file changed, 8 deletions(-)
tnkim@tnkim-N53SV:~/git/fx500machlink$ git push
Counting objects: 13, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (7/7), 561 bytes, done.
Total 7 (delta 3), reused 0 (delta 0)
To gitolite@sf.thinkware.co.kr:tnkim/fx500machlink.git
   ce7c426..8f44b60  fx500machlink_with_standardtimeout -> fx500machlink_with_standardtimeout