10 Advanced Git Commands You Should Know
Hey folks! 👋
So after surviving git init
, git add
, and all the noob stuff on Day 1, it’s time to level up. Today, I explored some advanced Git commands, the kind that make you feel like a real dev.
Here’s a breakdown of 10 Git commands every serious coder should know.
1. git diff
This command shows the differences between your commits or files.
git diff
💬 "You edited something? Git will show you exactly what's different."
2. git log
This one gives you a detailed history of your commits — author, time, hash, message.
git log
💬 "Kinda like your browser history, but for code. No incognito mode here."
3. git clone
You can bring a GitHub repo to your local system with this:
git clone
🧠 Note: If someone made changes to the repo after you cloned, your local copy won’t have those changes unless you pull them.
4. git fork
When you fork a repo on GitHub, you’re creating a full copy of someone else's repo into your GitHub account.
Useful when:
- You want to contribute
- You want to customize it as your own
👨🍳 "Think of it like copying your friend’s biryani recipe to your own recipe book and adding extra spice 🌶️."
5. git pull
It fetches and merges changes from the remote to your local branch.
git pull origin main
💬 "If someone else made changes, this is how you get them."
6. git push
This uploads your local commits to GitHub.
git push origin main
💬 "Think of it as ‘post to Instagram’ but for code."
7. git blame
This shows who wrote each line of code.
git blame
💬 "Want to know who broke the build? Blame 'em. Literally."
8. Merge Conflicts 🥲
When two people make conflicting changes in the same file — Git will cry. And so will you.
Fix it by:
- Reading the conflict markers (
<<<<<<<
,=======
,>>>>>>>
) - Deciding what to keep
- Committing the resolved file
💬 "It’s like two friends editing a group message at the same time… someone’s gonna get mad."
9. git branch
Used to create or list branches.
git branch feature-x
💬 "Work on new features without messing up your main code. Like parallel universes, but for bugs."
10. .gitignore
Used to exclude files/folders from being pushed to GitHub.
Just create a .gitignore
file and list things like:
node_modules/
.env
*.log
💬 "Hide your secrets and junk before pushing your repo into the world."
Thanks for reading! Hope this post made advanced Git feel a little less scary and a lot more fun