# Branch - List all branches. The current one is marked with * git branch - Create a new branch git branch [branch_name] - Switch to a branch git checkout [branch_name] - Create a new branch and switch to it git checkout -b [branch_name] - Switch to the previously checked out branch git checkout - - Rename a branch git checkout -m [new_branch] - Delete a branch, locally git branch -d [branch_name] - Merge another branch into the current one git merge [branch_name] # History - Reset to certain commit and also reset working tree git reset --hard hash - Reset to certain commit and keep working tree git reset --soft hash - Reset to origin/master git reset --hard origin/master - Checkout certain commit (move HEAD only, keep branch pointer) git checkout [hash] - Checkout back to master (move HEAD back to branch pointer) git checkout master # Submodule - Initializes and updates submodules recursively to match the repository git submodule update --init --recursive - Updates submodules recursively to the latest commit on their remote git submodule update --remote --recursive - Add submodule to local repository git submodule add [local]