GitHub Basics CheatSheet
Basic GitHub commands for solo developers
API: /api/v1/cheatsheet/github-basics-cheatsheet
Git / GitHub Cheat Sheet
Check where you are
Before doing Git commands, make sure you are inside the correct project folder:
⧉
1 | |
List files:
⧉
1 | |
Check Git status:
⧉
1 | |
If you see:
⧉
1 | |
you are either in the wrong folder or you have not run git init yet.
Initialize a local Git repo
Use this when your project folder is not yet a Git repo.
⧉
1 | |
Set the branch name to main:
⧉
1 | |
Check status:
⧉
1 | |
Add a .gitignore
Create a file called:
.gitignore
Important: .gitignore should be in the repo root, for example:
my-repo/ ├── .git/ ├── .gitignore ├── module_1/ ├── module_2/ └── module_3/
For Python projects, use something like:
⧉
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | |
First upload to GitHub
When you are uploading the project for the first time:
1: Stage files
⧉
1 | |
Step 2: Commit files
⧉
1 | |
Step 3: Connect to GitHub repo
Use your own GitHub repo URL:
⧉
1 | |
Step 4: Push to GitHub
⧉
1 | |
After this, refresh GitHub. Your files should appear.
Normal update workflow
Use this after you add, edit, rename, or delete files.
⧉
1 2 3 4 | |
For one specific file:
⧉
1 2 3 | |
Pull changes from GitHub
Run this when GitHub has changes that your local machine does not have:
⧉
1 | |
Or explicitly:
⧉
1 | |
Use pull before starting work if you use multiple computers or edit files on GitHub directly.
Fix “fetch first” error
Error:
⧉
1 | |
This means GitHub has commits that your local repo does not have.
Try:
⧉
1 2 3 4 5 6 7 8 9 | |
Check your remote GitHub repo
Show connected GitHub repo:
⧉
1 | |
Expected output:
⧉
1 2 | |
Change the remote URL:
⧉
1 | |
Remove the remote:
⧉
1 | |
Branch basics
Show branches:
⧉
1 | |
Create a new branch:
⧉
1 | |
Switch branches:
⧉
1 | |
Modern equivalent:
⧉
1 | |
Rename current branch to main:
⧉
1 | |
Delete a local branch:
⧉
1 | |
Push a new branch to GitHub:
⧉
1 | |
Remove files from Git tracking but keep them locally
Useful if you accidentally added venv/, .env, or pycache/.
⧉
1 2 3 | |
Then commit:
⧉
1 2 | |
If you already updated .gitignore, you can also do:
⧉
1 2 3 4 | |
Authentication with GitHub
GitHub does not accept your account password for Git pushes over HTTPS.
When asked for credentials:
- Username: your GitHub username
- Password: your GitHub personal access token
Join the Newsletter
Practical insights on Django, backend systems, deployment, architecture, and real-world development — delivered without noise.
Get updates when new guides, learning paths, cheat sheets, and field notes are published.
No spam. Unsubscribe anytime.
There is no third-party involved so don't worry - we won't share your details with anyone.