10 Essential Git Commands Every Developer Should Know

๐๐ป๐๐ฟ๐ผ๐ฑ๐๐ฐ๐๐ถ๐ผ๐ป
Git is the backbone of modern development workflows. Whether you're working on a solo side project or collaborating with a large team, mastering Git commands is essential. In this post, weโll go over 10 fundamental Git commands that every developer should know to manage code efficiently and confidently.
๐ง ๐ญ. ๐ด๐ถ๐ ๐ถ๐ป๐ถ๐
Initializes a new Git repository in your project folder.
๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ
This creates a .git directory and enables version tracking for your files.
๐ ๐ฎ. ๐ด๐ถ๐ ๐ฐ๐น๐ผ๐ป๐ฒ
Clones an existing Git repository (usually from GitHub) to your local machine.
๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ:ฬฒ/ฬฒ/ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ.ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ/ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ/ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ.ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ
You get a full copy of the repo including history and branches.
๐พ ๐ฏ. ๐ด๐ถ๐ ๐ฎ๐ฑ๐ฑ
Stages changes in your working directory for the next commit.
๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒโฬฒ.ฬฒ
or
git add filename.js
Use . to add all changes, or specify individual files.
โ ๐ฐ. ๐ด๐ถ๐ ๐ฐ๐ผ๐บ๐บ๐ถ๐
Saves your staged changes to the local repository with a message.
๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒโฬฒโฬฒ๐ฬฒโฬฒ"ฬฒ๐ฐฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ"ฬฒ
Each commit is like a snapshot of your project at a moment in time.
๐ ๐ฑ. ๐ด๐ถ๐ ๐ฝ๐๐๐ต
Uploads your local commits to a remote repository like GitHub.
๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ
Make sure you're pushing to the correct branch (main, master, or others).
โฌ๏ธ ๐ฒ. ๐ด๐ถ๐ ๐ฝ๐๐น๐น
Fetches changes from the remote repo and merges them into your local branch.
๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ
Useful for syncing changes made by others before you start new work.
๐ ๐ณ. ๐ด๐ถ๐ ๐๐๐ฎ๐๐๐
Shows the current state of your working directory and staging area.
๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ
Tells you which files are modified, staged, or untracked.
๐ ๐ด. ๐ด๐ถ๐ ๐ฐ๐ต๐ฒ๐ฐ๐ธ๐ผ๐๐
Switches to a different branch or restores files.
๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒโฬฒโฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ
Use -b to create a new branch and switch to it at once.
๐งน ๐ต. ๐ด๐ถ๐ ๐ฏ๐ฟ๐ฎ๐ป๐ฐ๐ต
Lists branches or creates new ones.
๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ
or
๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ
Keep your main branch clean by developing in separate branches.
โช ๐ญ๐ฌ. ๐ด๐ถ๐ ๐น๐ผ๐ด
Displays commit history.
๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒโฬฒโฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ
See who made which changes and when โ great for debugging and collaboration.
๐ง ๐๐ผ๐ป๐๐: ๐๐ผ๐บ๐บ๐ผ๐ป ๐ง๐ฟ๐ผ๐๐ฏ๐น๐ฒ๐๐ต๐ผ๐ผ๐๐ถ๐ป๐ด ๐๐ผ๐บ๐บ๐ฎ๐ป๐ฑ๐ ๐จ๐ป๐ฑ๐ผ ๐น๐ฎ๐๐ ๐ฐ๐ผ๐บ๐บ๐ถ๐:
๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒโฬฒโฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ทฬฒ๐ดฬฒ๐ฐฬฒ๐ณฬฒ~ฬฒ๐ทฬฒ
Discard all local changes:
๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒโฬฒโฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ
๐ฅ๐ฒ๐บ๐ผ๐๐ฒ ๐๐๐ฎ๐ด๐ฒ๐ฑ ๐ณ๐ถ๐น๐ฒ:
๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒโฬฒ๐ทฬฒ๐ดฬฒ๐ฐฬฒ๐ณฬฒโฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ๐ฬฒ
๐ ๐๐ผ๐ป๐ฐ๐น๐๐๐ถ๐ผ๐ป These Git commands form the foundation of version control. Whether you're a junior developer or working in DevOps, mastering these will improve your confidence and collaboration in any codebase. Bookmark this post or share it with a teammate whoโs just getting started!