Show Menu

HMI Git/Gerrit Cheat Sheet by

Git and Gerrit with BCI


Identi­fying 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­e5c044b

Local changes

Changes in your working directory
git status

Add a single file to the next commit
git add filename

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-123456

Pull HMI_master and rebase on top of it
git pull --rebase HMI_master

List all branches
git branch -a

Delete a branch (HMI-1­23456)
git branch -d HMI-123456

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-123456

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-123456
Ticket ID in the example is HMI-123456

Finding your change on Gerrit

Check the link in push to Gerrit output

remote: Updated Changes:

remote:   https:­//a­sc.b­mw­gro­up.n­et­/ge­rri­t/32677


Monitoring build progress



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