Development Tip

Use gerrit with git push command.

Lots2Talk 2013. 2. 20. 17:59

Repo 로 이루어진 project 중 하나의 git project 만 clone 을 받아(새로 생성 및 전체 project 가 필요없는 경우) 소스를 수정하고 repository 로 push 할 때, gerrit 을 이용하도록 하는 command 를 소개(?) 한다.


Git Clone

$ git clone ssh://username@hostname:29418/Repository_name.git


Modifiy

$ vi source.cpp


Git push

$ git push ssh://username@hostname:29418/projectname.git HEAD:refs/for/branchname


위와 같이 하면 gerrit review 에 commit 이 "open" 상태로 보이게 된다. 


일반적으로 git push <remote> <branch> 하면 gerrit review 없이 바로 submit 되기 때문에 review 를 받지 않게 되는데 위와 같이 진행하면 repo upload 하는 효과를 볼 수 있다.


git push 할 때마다 저렇게 길게 입력 하는 것보다 .git/config 를 수정하여 간편하게 할 수 있다.


$ cd <git repository>

$ vi .git/config

에 아래와 같이 추가

[remote "for-review"]

fetch = +refs/heads/*;refs/remotes/origin/*

url = ssh://hostname:29418/repository_name.git

push = HEAD:/refs/for/branch_name


fetch = 에 origin은 remote name 임(git branch -a 로 확인)


위와 같이 수정하고 push 할 때는

$ git push for-review

하면 됨.


reference : https://git.eclipse.org/r/Documentation/user-upload.html