Git cheat sheet

Git-Logo-1788C.png


Add specified <file> to your list of commits.
git add <file>

Amend the current changes. Typically done after cherry-pick from gerrit.
git commit --amend

Fetch and Merge from the remote depot.
git pull --rebase

Update all submodules
git submodule update --init --recursive

Delete a local branched named 'test'.
Will fail if the specified branch has orphaned changes.
git branch -d test

Force deletion of a local branch named 'test'.
git branch -D test

Display all branches even the remote once.
git branch -av

Switch to a branch names 'local'.
git checkout local

Shows your local branches including the one you have currently checked out.
git branch

Create a local branch from a remote one
git checkout -b test-local remotes/origin/test

Shows which branch you have currently checked out and the status of local files.
git status

Run this from your working branch to update from your local master.
git rebase master

List the history, last change first.
git log

Revert all you changes
git reset --hard

Abort a cherry pick
git reset --merge

Stash management
git stash save
git stash apply
git stash pop
git stash list

Rebase
git rebase -i master PowerVR-update

Merge changes from the specified branch onto the current branch
git merge thatbranch

Merge back to master
git merge --no-ff mybranch

Tortoise dialog
TortoiseProc /command:log /path:.

To cherry-pick a merge. -m 1 reference to the first parent of the merge as listed on gerrit.
git cherry-pick -m 1 FETCH_HEAD

To delete your latest commit from your history
USE THIS CAREFULLY, YOU ALSO LOOSE ALL LOCAL CHANGES
git reset --hard HEAD^

Squash the last 2 commits. Commit messages are lost. You'll need to commit again after the soft reset.
git reset --soft HEAD~2

BEWARE: Delete untracked files
git clean -f
 
Last edited:
Top