0

We have been using gerrit as our android source code repo. We usually use git bash commands to do push ,pull and commit for working with gerrit.I want to how we can configure the android studio itself with gerrit so that i don't need to type in commands in git bash. I tried to change some settings in the Android studio in git version control option but that really didn't work. One more thing is that whenever we do a commit through git commit command git creates (or something else i am sure as i am not very good at git commands and env) changeId: This is very important for pushing/amending the changes.How can i add changeId while i commit from studio.

Let me know if i am not very clear about my question , i will add more.

This is the image of my push Ui from studio where i can't see the origin HEAD :

enter image description here

anshul
  • 982
  • 1
  • 11
  • 33

1 Answers1

2

Android Studio’s Git GUI should be able to do almost all the jobs through menus and buttons. The only annoying thing may be that you need to change the remote ref in the push menu from master or refs/heads/master to refs/for/master to create changes for review.

Change-Id is created by a hook commit-msg. As I know, it is under repo/hooks if you use Google’s REPO. The repositories cloned by repo sync have commit-msg deployed, so you don’t need to worry about it. But as for those repositories created by git clone or git init, you need to install it. Gerrit’s project page provides a clone command which includes scp that downloads and copies the hook automatically. If you clone through Android Studio, you could manually install it under .git/hooks/ for one repository, or copy it to $GITBASH/ming64(32)/share/git-core/template/hooks on Windows so that any new created repository will have it installed automatically.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53
  • Thanks for the answer @ElpieKay ChangeId i was able to add but the problem is the push. The command i use from git bash to push is git push origin HEAD:refs/for/master and in the studio i cant see origin HEAD : , i can only see origin : which is not letting me push. Checkout the question again i have added the pic – anshul Oct 31 '17 at 09:12
  • @anshul It seems okay as you change the destination to `refs/for/master`. But, you have a merge commit `Merge remote tracking branch 'origin/master'`. By default, the hook `commit-msg` is not invoked when a merge happens, so the merge commit doesn't have `Change-Id` in its message unless you run `git commit --amend` right after the merge is done. – ElpieKay Oct 31 '17 at 09:24
  • Great Thanks a ton buddy. – anshul Oct 31 '17 at 09:36
  • @anshul My pleasure. Glad it helps. – ElpieKay Oct 31 '17 at 09:37
  • You can check (and set) the push configuration with "git config remote.origin.push", it should be: remote.origin.push=refs/heads/master:refs/for/master, then android studio should use that as default for push – beka May 16 '19 at 16:45