Git Commands Cheat Sheet
1. Quick Reference | Command | Description | | --- | --- | | git init | Initialize a new Git repository | | git clone [url] | Clone a Git repository from a URL | | git add [file] | Stage a file ...
TechSilo
AI-assisted and human-curated
1. **Quick Reference**
| Command | Description |
| --- | --- |
| git init | Initialize a new Git repository |
| git clone [url] | Clone a Git repository from a URL |
| git add [file] | Stage a file for commit |
| git commit -m "[message]" | Commit changes with a message |
| git log | Display commit history |
| git branch [branch] | Create a new branch |
| git checkout [branch] | Switch to a branch |
| git merge [branch] | Merge a branch into the current branch |
| git remote add [name] [url] | Add a remote repository |
| git push [remote] [branch] | Push changes to a remote repository |
| git pull [remote] [branch] | Pull changes from a remote repository |
2. **Syntax**
* git [command] [options] [arguments]
* git [command] --[option] [value]
* Placeholders:
+ [file]: file name or path
+ [message]: commit message
+ [branch]: branch name
+ [remote]: remote repository name
+ [url]: repository URL
3. **Common Patterns**
* Create a new branch and switch to it:
git branch [branch]
git checkout [branch]* Stage all changes and commit with a message:
git add .
git commit -m "[message]"* Push changes to a remote repository:
git push [remote] [branch]* Pull changes from a remote repository and merge into the current branch:
git pull [remote] [branch]4. **Gotchas**
* Forgetting to stage changes before committing: use git add . to stage all changes
* Not specifying a commit message: use git commit -m "[message]"
* Trying to push to a non-existent remote repository: use git remote add [name] [url]
* Not pulling changes from a remote repository before pushing: use git pull [remote] [branch]
5. **Related Commands**
* git status: display the status of the repository
* git diff: display differences between files
* git tag [tag]: create a new tag
* gitk --all: display a graphical representation of the commit history
* git config --global [option] [value]: set global Git configuration options
Want to put this into practice?
Explore TechSilo's free developer tools for practical utilities you can use directly in your browser.
Related blog posts
CSS Flexbox Cheat Sheet: Alignment, Wrapping, and Responsive Rows
A practical CSS Flexbox reference covering display:flex, flex-direction, gap, justify-content, align-items, flex-wrap, and flex shorthand.
Read postCSS Grid Cheat Sheet: Columns, Rows, Areas, and Responsive Layouts
A practical CSS Grid reference with repeat(), minmax(), auto-fit, alignment, named areas, and responsive layout examples.
Read postnpm Scripts Cheat Sheet: Commands, Arguments, and Automation
A developer reference for package.json scripts, npm run, pre/post hooks, environment variables, and safe task automation.
Read postTypeScript Utility Types Cheat Sheet: Pick, Omit, Partial and More
Practical examples of TypeScript Partial, Required, Pick, Omit, Record, ReturnType, Awaited, Extract, and Exclude.
Read postVS Code Shortcuts Cheat Sheet
To customize your VS Code shortcuts, you can use the following syntax in your keybindings.json file:
Read post