title: Git Sheet description: A simple git cheatsheet. category: git date: '2022-06-08T00:00:00.000Z'
Git Sheet
A simple git cheatsheet.
Branches
- list all local branches.
- list remote and local branches.
- Create a local branch and switch to it.
- Switch to an existing branch.
- Push branch to remote.
- Rename current branch.
- Delete a local branch.
- Delete a remote branch.
- Print all branches that have been merged into master.
Logs
- Show commit history in single lines.
- Show commit history for last N commits.
- Show commit history for last N commits with diff.
- Show all local file changes in the working tree.
- Show changes made to a file.
- Show who changed what & when in a file.
- Show remote branches and their mapping to local.
Cleanup
- Delete all untracked files.
- Delete all untracked files and directories.
- Undo local modifications to all files.
- Unstage a file.
Tags
- Get remote tags.
- Switch to an existing tag.
- List all tags.
- Create a new tag.
- Push all tags to remote repo.
Stashes
-
Save changes to a stash.
-
List all stashes.
-
Apply a stash and delete it from stash list.