First, run ssh-keygen
in your terminal, and accept all of the default parameters by hitting enter. Then go to Gerrit, click on your name in the top right corner and click settings. Choose SSH Public Keys
on the side bar and click Add Key
. Copy paste the contents of ~/.ssh/id_rsa.pub
into the box and hit okay.
If you used the clone with commit-msg hook
command when you first cloned the code, you can skip this step. If you did not, run the following commands from the 971-Robot-Code directory, replacing <username>
with your gerrit username.
scp -p -P 29418 <username>@software.frc971.org:hooks/commit-msg .git/hooks/
git status
git diff
to see exactly what you changed. Note that this will not show you new files that you've created locally.Once you know what you want to commit, use git add <file>
to "stage" them for the commit. You should only add the changes that you want, so if your files contain things you don't want to commit, you'll have to cut out the stuff you don't want before using git add
.
After you've used git add
to add all the changes you want to commit, run git commit -s
and write an informative commit message in the editor that pops up. Save and quit in the editor that opens to actually commit your changes. If you change your mind about committing, you can quit without saving to cancel the commit.
git commit -v
to see what changes git
thinks you want to commit in the commit message editor.git commit -m "<message>"
to specify it on the command line.-s
adds a signed-off-by trailer to put your name on the review for open sourcing.Send your changes to Gerrit by running git push origin HEAD:refs/for/main
.
Add reviewers to your change request so that your code can be reviewed and approved after feedback.
Gerrit allows you to edit your change and resubmit it.
Make sure that the commit you want to edit is the latest in your commit history by running git show
and making sure that the commit is the one you want to edit.
Make the changes you want to make.
Add the changes using git add <file1> <file2> ...
.
Add the changes you made to the previous commit by running git commit --amend -s
. This will allow you to edit the previous commit message. MAKE SURE YOU DON'T EDIT THE GERRIT Change-Id. This is what Gerrit uses to know that you're updating an existing change instead of pushing a new one.
Send the updated change to Gerrit with git push origin HEAD:refs/for/main
.
Counting objects: 5, done. Delta compression using up to 4 threads. Compressing objects: 100% (5/5), done. Writing objects: 100% (5/5), 2.83 KiB | 0 bytes/s, done. Total 5 (delta 1), reused 0 (delta 0) remote: Resolving deltas: 100% (1/1) remote: Processing changes: refs: 1, done remote: ERROR: [bf965b4] missing Change-Id in commit message footer remote: remote: Hint: To automatically insert Change-Id, install the hook: remote: gitdir=$(git rev-parse --git-dir); scp -p -P 29418 adrian@software.frc971.org:hooks/commit-msg ${gitdir}/hooks/ remote: And then amend the commit: remote: git commit --amend remote:
If you see this, run the commands that they suggest in the error message and push it again