Git CheatSheet

28 Mar 2019

Branches

Settings

Set username:

get config --global user.name "MyName"

Set mail address:

get config --global user.email "my@mail.address"

Rename local branch

If you are on the branch

git branch -m new-name

If you are on a different branch

git branch -m old-name new-name

Rename remote branch

git push origin :old-name new-name

Reset upstream branch

git push origin -u new-name

Delete a remote branch

git push origin :branch-name

Merges

Multiple sign-off

Sign off all single commits from a branch and cherry-pick them to the master branch

git cherry -v master BRANCH-YOU-LIKE-TO-MERGE | cut -f2 -d ' ' | while read LINE; do git cherry-pick -s ${LINE}; done

Add a comment