% git # Initializes a git repository git init # Clone a git repository git clone # Rebase upstream master into local/origin master git fetch git checkout master git rebase /master git fetch origin git push -f origin master # Merge upstream master into local/origin master git fetch git checkout master git merge /master git fetch origin git push -f origin master # Adds a remote for a git repository git remote add # Renames a remote for a git repository git remote rename # Remove a remote for a git repository git remote remove # Saves the changes to a file in a commit git commit -m # Pushes committed changes to remote repository git push --set-upstream # Displays formatted log of commits for a repo git log --all --decorate --oneline --graph # Clean everything git clean -fdx # Add a new module git submodule add # Update module git submodule update --init # Update module without init git submodule update # Pull all submodules git submodule foreach git pull origin master # Skip git hooks git commit --no-verify # Create new branch from current HEAD git checkout -b # Create and push tag git tag git push origin # Delete and push tag git tag -d git push -d origin # Create a patch from current full diff git diff > .patch # Create a patch from current file diff git diff > .patch # Create a patch from commit(s) git format-patch .. # Show a diff patch git apply --stat # Check a diff patch git apply --check # Apply a diff patch git apply # Apply a commit patch git am # Variables $ tag_name: git tag -l | awk '{print $1}' $ diff_file: git diff --name-only | awk '{print $1}' $ first_commit: git log -n 20 --oneline | fzf --preview 'git show --color=always {1}' | awk '{print $1}' $ last_commit: git log -n 20 --oneline | fzf --preview 'git show --color=always {1}' | awk '{print $1}' $ patch_name: ls *.patch | awk '{print $1}'