Here are some of the common git sequence of commands stolen from Stack Over Flow answers for ease of refrence


Break specific commit into multiple commits

1- Split apart your most recent commit:

$ git reset HEAD~

2- if you want older commit

$ git rebase -i HEAD~n

When you get the rebase edit screen, find the commit you want to break apart. At the beginning of that line, replace “pick” with “edit”. Save the buffer and exit. Rebase will now stop just after the commit you want to edit. Then:

$ git reset HEAD~

Commit the pieces individually in the usual way, producing as many commits as you need, then

$ git rebase --continue

Beautifully print out git logs

$ git log --pretty=oneline --abbrev-commit

Patchset formatting and sending

for Format patchset with cover letter, where N is number of patches you want to include

$ git format-patch -o ~/dir/to/save/into -nN --cover-letter 

Send patches via git ,ofcourse after you setup your email configuration proberly!

$ git send-email --annotate ~/dir/of/patch/you/want/to/send

To go to a specific commit files

$ git checkout "SHA"

then to return to the current assuming branch name is master

$ git checkout master

Commands related to branching

$ git branch
$ git branch name-of-branch
$ git checkout name-of-branch
$ git branch -d the_local_branch

X: the commit to modify

$ git rebase --interactive X^

In the default editor, modify ‘pick’ to ‘edit’ in the line whose commit you want to modify. Make your changes and then commit them with the same message you had before:

$ git commit -a --amend --no-edit
$ git rebase --continue

Recovering from detached HEAD

$ git checkout -b temp "SHA"
$ git checkout -B master temp
$ git branch -d temp

Here are more links I’ve found helpful: Reset a specific file to a specific revision using git , Undoing git reset , Or just use this Cheat sheet already made by Github!