0% found this document useful (0 votes)
9 views1 page

Basic Git Command Cheat Sheet

This document is a cheat sheet for basic Git commands, providing essential commands for initializing a repository, managing files, and interacting with GitHub. It includes commands for adding files, committing changes, viewing history, and branch management. Each command is accompanied by notes for clarity and best practices.

Uploaded by

deviant18024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

Basic Git Command Cheat Sheet

This document is a cheat sheet for basic Git commands, providing essential commands for initializing a repository, managing files, and interacting with GitHub. It includes commands for adding files, committing changes, viewing history, and branch management. Each command is accompanied by notes for clarity and best practices.

Uploaded by

deviant18024
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

📄 Basic Git Command Cheat Sheet

Action Command Notes


Initialize Git in a git init Creates a .git folder.
folder
Check current git status
Shows changes and
status branch info.
Add all files to git add . . means "everything."
staging
Add one specific git add filename.js
file
Commit changes Always write meaningful
git commit -m "your commit message"
messages!
View commit Press q to quit log view.
history git log

Connect local repo git remote add origin


to GitHub https://github.com/yourrepo.git
Only needed once.
Push code to git push -u origin main
First time push. Later, just
GitHub git push .

Clone a repo
git clone Copies a repo to your
https://github.com/username/repo.git computer.
Pull latest git pull origin main Updates your local copy.
changes
Create a new git checkout -b feature-branch-name
-b means "create and
branch switch."
Switch branches git checkout branch-name

Merge a branch → git merge branch-name Always test before


into main git checkout main
merging!
Delete a branch After merging it.
locally git branch -d branch-name

See all branches Current branch is marked


git branch
with * .

You might also like