confused between GIT & Gerrit

2,178 views
Skip to first unread message

Sai Krishna

unread,
Apr 7, 2012, 1:59:30 AM4/7/12
to Repo and Gerrit Discussion
Hi All,

I am a newbie to Gerrit and has been using GIT for the past 3 months.
I have recently set it up in my office but I am getting some what
confused between GIT & Gerrit.

I have tried to realize most of the issues with help of Google but
couldn't find answer to these questions.

1. Why does my developers git log and gerrit git log vary some times.
While I was use git alone git log used to exactly the same.

2. Can a developer pull new changes even before his change is
approved ??. When we did so, git pull, and trying to submit a new
patch gerrit gives an error saying change already submitted.

3. Can we "git push" changes on one branch to another branch on
gerrit ??. Like if I am working on master can I push changes to test-
branch ?? or vice versa ?

4. How do I merge the branches on gerrit. Should it be done gerrit
server or can any of my developers do that ?

Some of the question might sound very naive, but I did my best to find
the answers :)

regards,
Sai Krishna.

Magnus Bäck

unread,
Apr 7, 2012, 9:43:26 PM4/7/12
to Repo and Gerrit Discussion
On Sat, Apr 7, 2012 at 1:59 AM,
Sai Krishna <pvsaik...@gmail.com> wrote:

[...]

> 1. Why does my developers git log  and gerrit git log vary some times.
> While I was use git alone git log used to exactly the same.

They will be the same if you have fetched sufficiently recently. There
is no difference between Gerrit and plain Git in this area.

> 2. Can a developer pull new changes even before his change is
> approved ??. When we did so, git pull, and trying to submit a new
> patch gerrit gives an error saying change already submitted.

You can always run "git fetch" to update the remote branches in your
git, but you shouldn't use "git pull" unless you use the --rebase
option. If you do a regular "git pull" you'll get a merge commit
(assuming you have made at least one local commit), and that merge
commit would be uploaded for review to Gerrit. You don't want that.

> 3. Can we "git push" changes on one branch to another branch on
> gerrit ??. Like if I am working on master can I push changes to test-
> branch ?? or vice versa ?

Each commit will only be reviewed once, so it won't work as described
by you. If you're bypassing review (pushing to refs/heads/branchname)
then it'll work if the branch you're pushing to can be fast-forwarded
to the commit you're pushing.

What is it you want to do? Perhaps you should merge the two branches
and push the merge commit to either refs/for/branchname or
refs/heads/branchname.

> 4. How do I merge the branches on gerrit. Should it be done gerrit
> server or can any of my developers do that ?

Nothing needs to be done on the server. To upload merges as changes
(i.e. they'll be subject to a review) you just need the "upload merge
commits" permission. If you want to push merge commits and bypass
review (i.e. push to refs/heads/foo rather than refs/for/foo) you need
the "push" permission.

--
Magnus Bäck
ba...@google.com

Reply all
Reply to author
Forward
0 new messages