Here are some of the common git sequence of commands stolen from Stack Over Flow answers for ease of refrence
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
$ git log --pretty=oneline --abbrev-commit
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
$ git checkout "SHA"
then to return to the current assuming branch name is master
$ git checkout master
- To check current branches:
$ git branch
- To create new branch
$ git branch name-of-branch
- To change to particular branch
$ git checkout name-of-branch
- To delete a branch locally
$ git branch -d the_local_branch
- Amend specific commit:
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
$ 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!