Ultimate GitHub Markdown and Command Cheat Sheet

Welcome to the ultimate GitHub cheatsheet! This guide combines essential GitHub commands with comprehensive Markdown syntax. Whether you're managing repositories or creating well-formatted README files, this cheatsheet has got you covered.
Table of Contents
1. [GitHub Commands](#github-commands)
- [Setup and Configuration](#setup-and-configuration)
- [Repository Management](#repository-management)
- [Branching and Merging](#branching-and-merging)
- [Staging and Committing](#staging-and-committing)
- [Pushing and Pulling](#pushing-and-pulling)
- [Cloning Repositories](#cloning-repositories)
- [Viewing History](#viewing-history)
- [Undoing Changes](#undoing-changes)
- [Working with Remote Repositories](#working-with-remote-repositories)
2. [Markdown Syntax](#markdown-syntax)
- [Headings](#headings)
- [Paragraphs](#paragraphs)
- [Line Breaks](#line-breaks)
- [Emphasis](#emphasis)
- [Blockquotes](#blockquotes)
- [Lists](#lists)
- [Code](#code)
- [Horizontal Rules](#horizontal-rules)
- [Links](#links)
- [Images](#images)
- [Tables](#tables)
- [Task Lists](#task-lists)
- [Mentions and References](#mentions-and-references)
- [Emoji](#emoji)
GitHub Commands
Setup and Configuration
Install Git
Download and install Git from the official [Git website](https://git-scm.com/).
Configure Git
Set your username and email address:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
Repository Management
Initialize a Repository
Create a new Git repository:
git init
Clone a Repository
Clone an existing repository:
git clone https://github.com/username/repository.git
Branching and Merging
Create a New Branch
Create and switch to a new branch:
git checkout -b new-branch
Switch Branches
Switch to an existing branch:
git checkout branch-name
Merge Branches
Merge a branch into the current branch:
git merge branch-name
Staging and Committing
Stage Changes
Add a file to the staging area:
git add filename
Stage all changes:
git add .
Commit Changes
Commit staged changes:
git commit -m "Commit message"
Pushing and Pulling
Push Changes
Push changes to a remote repository:
git push origin branch-name
Pull Changes
Fetch and merge changes from a remote repository:
git pull origin branch-name
Cloning Repositories
Clone a Repository
Clone a repository from GitHub:
git clone https://github.com/username/repository.git
Viewing History
View Commit History
View the commit history of the repository:
git log
View a Specific Commit
Show details of a specific commit:
git show commit-id
Undoing Changes
Unstage Changes
Unstage a file:
git reset HEAD filename
Revert Changes
Revert changes in a file:
git checkout -- filename
Amend Last Commit
Amend the last commit:
git commit --amend -m "New commit message"
Working with Remote Repositories
Add a Remote Repository
Add a new remote repository:
git remote add origin https://github.com/username/repository.git
Remove a Remote Repository
Remove a remote repository:
git remote remove origin
List Remote Repositories
List all configured remote repositories:
git remote -v
Markdown Syntax
Headings
Use #
for headings. The number of #
determines the heading level.
# H1
## H2
### H3
#### H4
##### H5
###### H6
H1
H2
H3
H4
H5
H6
Paragraphs
Separate paragraphs with a blank line.
This is a paragraph.
This is another paragraph.
This is a paragraph.
This is another paragraph.
Line Breaks
End a line with two spaces for a line break.
This is the first line.
This is the second line.
This is the first line.
This is the second line.
Emphasis
Use *
or _
for italic, and **
or __
for bold.
*Italic* _Italic_
**Bold** __Bold__
~~Strikethrough~~
ItalicItalic
BoldBoldStrikethrough
Blockquotes
Use >
to create blockquotes.
> This is a blockquote.
This is a blockquote.
Lists
Unordered List
Use *
, +
, or -
for unordered lists.
* Item 1
* Item 2
* Subitem 1
* Subitem 2
Item 1
Item 2
Subitem 1
Subitem 2
Ordered List
Use numbers for ordered lists.
1. Item 1
2. Item 2
1. Subitem 1
2. Subitem 2
Item 1
Item 2
Subitem 1
Subitem 2
Code
Inline Code
Use backticks for inline code.
`inline code`
inline code
Code Blocks
Use triple backticks or indentation for code blocks.
```markdown
```
code block
```
code block
code block
Horizontal Rules
Use ---
, ***
, or ___
for horizontal rules.
---
***
___
Links
Use [text](URL)
for links.
[GitHub](https://github.com)
Images
Use 
for images.

Tables
Use |
to create tables.
| Header 1 | Header 2 |
| -------- | -------- |
| Cell 1 | Cell 2 |
| Cell 3 | Cell 4 |
Header 1 | Header 2 |
Cell 1 | Cell 2 |
Cell 3 | Cell 4 |
Task Lists
Use - [ ]
for task lists.
- [x] Task 1
- [ ] Task 2
- [ ] Task 3
[x] Task 1
[ ] Task 2
[ ] Task 3
Mentions and References
Use @
to mention a user and #
to reference an issue or pull request.
@username
#123
Emoji
Use :emoji_name:
for emojis. GitHub supports emoji.
:smile:
:smile:
This ultimate cheatsheet provides a quick reference to the most commonly used GitHub commands and Markdown syntax. Whether you're managing code repositories or creating documentation, these commands and syntax will help you streamline your workflow on GitHub. Happy coding!
This document combines both GitHub commands and Markdown syntax into one cheatsheet. It is designed to be a comprehensive reference for both aspects of working with GitHub, from repository management to formatting README files. Save this text to a `.md` file, and you'll have a handy guide at your fingertips!
Subscribe to my newsletter
Read articles from Rahul Nadola directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Rahul Nadola
Rahul Nadola
DevOps Enthusiast