Skip to content

Instantly share code, notes, and snippets.

@aeisenberg
Created June 26, 2018 20:53
Show Gist options
  • Save aeisenberg/b9e0b1ca47db44b306fd058e377c46ae to your computer and use it in GitHub Desktop.
Save aeisenberg/b9e0b1ca47db44b306fd058e377c46ae to your computer and use it in GitHub Desktop.
Clones a repository from gerrit and includes a default /refs/for/* clause
#! /bin/sh -e
server=gerrit.example.com # change to your own server
username=$1
project=$2
url=ssh://${username}@${server}:29418/${project}
git clone ${url}
cd ${project}
git config gerrit.createchangeid true
git config remote.origin.url ${url}
git config remote.origin.push HEAD:refs/for/master
git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
scp -p -P 29418 ${username}@${server}:hooks/commit-msg .git/hooks/
@aeisenberg
Copy link
Author

@chris3torek
Copy link

Minor: you don't need lines 9 and 11, git clone configures those two that way for you.

Somewhat more serious: you might want to make sure there are two arguments and if not, print a usage message. Still not too big a problem since if the arguments are inappropriate, the git clone step will fail and the -e flag will make the script exit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment