Cheat sheets
Git cheat sheet
Quick reference for the git commands you'll use day to day: initializing, saving changes, branches, and syncing with a remote.
Set up and start
git init- Initializes a repository in the current folder.
git clone <url>- Copies a remote repository to your machine.
git status- Shows modified/untracked files.
Save changes
git add file.py- Stages a file for the next commit.
git add .- Stages all changes in the current directory.
git commit -m "message"- Saves staged changes with a message.
git diff- Shows changes not yet staged.
git log --oneline- Commit history, one line each.
Branches
git branch- Lists local branches.
git checkout -b new-branch- Creates and switches to a new branch.
git switch other-branch- Switches to an existing branch.
git merge other-branch- Merges another branch's changes into the current one.
Working with a remote
git remote add origin <url>- Links a remote repository.
git push origin main- Pushes local commits to the remote.
git pull- Fetches and merges changes from the remote.
git fetch- Fetches changes from the remote without merging.