Show Menu

HMI Git/Gerrit Cheat Sheet by

Git and Gerrit with BCI


Iden­tifying a commit
Use first 4+ hash chars to identify a commit
git checkout 3e95 = git checkout 3e95b6­ad4­6ca­fd9­757­1b5­c05­7e1­ee5­dac­e5c­044b

Local changes

Changes in your working directory
git status
Add a single file to the next commit
git add filen­ame
Add all current changes to the next commit
git add .
Create a new commit from the previously added files
git commit
Modify an existing commit with the previously added files
git commit --amend
Delete all unvers­ioned files
git clean -f -n

Working with branches

Switching to a branch (HMI-1­23456)
git checkout HMI-12­3456
Pull HMI_master and rebase on top of it
git pull --rebase HMI_ma­ster
List all branches
git branch -a
Delete a branch (HMI-1­23456)
git branch -d HMI-12­3456
Cherry pick commit HASH to current branch
git cherry­-pick HASH

Rewriting history

Show last 3 commits
git log -3
Resetting to the previous commit (keep changes in workarea)
git reset HEAD~1
Resetting to the previous commit (revert changes)
git reset --hard HEAD~1
Reset to any commit by hash
git reset HASH

Gerrit / BCI

1. Create commit
git add .
git commit -m "­HMI­-123456 test"
2. Create a new branch named HMI-123456
git checkout -b HMI-12­3456
3. Push the commit to Gerrit
git push origin HMI-12­345­6:r­efs­/fo­r/H­MI_­mas­ter­%to­pic­=HM­I-1­23456
or Push to Gerrit with mhg
mgit ptg HMI-12­3456
Ticket ID in the example is HMI-123456

Finding your change on Gerrit

Check the link in push to Gerrit output
remote: Updated Changes:

Monitoring build progress

Help Us Go Positive!

We offset our carbon usage with Ecologi. Click the link below to help us!

We offset our carbon footprint via Ecologi


No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Git Cheat Sheet
          Bash Dev Cheat Sheet