15 Common Git Commands Every Developer Should Know

Git is an essential tool for modern software development. Whether you're working on solo projects or in a large team, mastering Git gives you power, safety, and collaboration superpowers.
In this post, let's go through 15 essential Git commands that every developer should know โ especially if you're just getting started.
๐ Original blog post here: 15 Git Commands on The Learn with Rana
1. git init
Initializes a new Git repository in your current project folder.
git init
2. git clone <url>
Clones a remote repository to your local machine.
git clone https://github.com/user/repo.git
3. git status
Displays the status of files โ staged, unstaged, or untracked.
git status
4. git add <file>
Stages a file for the next commit.
git add index.js
git add . # Add all changes
5. git commit -m "message"
Commits staged changes with a description.
git commit -m "Fix login bug"
6. git pull
Fetches and merges changes from a remote repository.
git pull origin main
7. git push
Pushes local commits to the remote repository.
git push origin main
8. git branch
Lists all branches or creates a new one.
git branch # List branches
git branch feature1 # Create a branch
9. git checkout <branch>
Switches to a specific branch and updates your working directory.
git checkout main
git checkout -b feature-xyz
10. git merge <branch>
Merges changes from one branch into the current one.
git merge feature-xyz
11. git log
Shows commit history.
git log
12. git diff
Displays differences between commits or working states.
git diff
git diff HEAD~1 HEAD
13. git stash
Temporarily saves uncommitted changes.
git stash
git stash pop
14. git reset
Unstages files or reverts commit history.
git reset file.js # Unstage
git reset --soft HEAD~1 # Keep changes
git reset --hard HEAD~1 # Discard everything
15. git remote -v
Lists all configured remote repositories.
git remote -v
๐ฏ Final Thoughts
These 15 Git commands form the backbone of version control for most projects. Mastering them gives you confidence and speed when building and collaborating.
๐ก Want a deeper dive? Check the full blog here:
๐ Original Blog Post โ The Learn with Rana
๐ฉ Have a favorite Git trick? Drop it in the comments!
๐ Follow me here on Hashnode and connect on LinkedIn for more practical dev content.
Happy committing! ๐
Subscribe to my newsletter
Read articles from RANA SAHA directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
