DEV Community

Cover image for πŸš€ Level Up with These 10+ Useful Git Commands
karthik santhosh
karthik santhosh

Posted on

πŸš€ Level Up with These 10+ Useful Git Commands

By Karthik Santhosh

Git is a powerful tool for developers β€” not just for saving your code, but for managing versions, collaborating, and resolving issues like a pro. In this post, let’s walk through some essential and advanced Git commands that can boost your workflow.


1. πŸ” git diff

Purpose: Show changes between files, commits, or branches.

Use Case: Compare your working directory with the index or a previous commit.

git diff
Enter fullscreen mode Exit fullscreen mode

2. πŸ“œ git log

Purpose: Display the full commit history.

Use Case: Track changes, find specific commits, or understand project history.

git log
Enter fullscreen mode Exit fullscreen mode

3. πŸ“₯ git clone

Purpose: Clone a remote repository to your local machine.

git clone https://github.com/karthikio/24MCR050
Enter fullscreen mode Exit fullscreen mode

4. ⬇️ git pull

Purpose: Fetch and merge changes from the remote repo to your current branch.

git pull origin main
Enter fullscreen mode Exit fullscreen mode

5. ⬆️ git push

Purpose: Push your local commits to the remote repository.

git push origin main
Enter fullscreen mode Exit fullscreen mode

6. πŸ•΅οΈ git blame

Purpose: Show who last modified each line of a file and when.

Use Case: Great for debugging or understanding change history.

git blame ML.txt
Enter fullscreen mode Exit fullscreen mode

7. βš”οΈ Merge Conflicts (Concept)

Note: Merge conflicts happen when two branches modify the same part of a file.

To simulate a merge conflict:

git checkout -b new-branch
# Make changes, commit them
git checkout main
# Make conflicting changes
git merge new-branch
# Conflict occurs here
Enter fullscreen mode Exit fullscreen mode

You'll need to manually resolve the conflict in the files and commit the resolution.


8. 🌿 git branch

Purpose: List, create, or delete branches.

git branch           # List branches  
git branch feature   # Create a branch  
git branch -d feature  # Delete a branch
Enter fullscreen mode Exit fullscreen mode

9. πŸš€ git checkout -b

Purpose: Create and switch to a new branch in one step.

git checkout -b advanced-git-commands
Enter fullscreen mode Exit fullscreen mode

10. πŸ“ .gitignore

Purpose: Tell Git which files or folders to ignore in version control.

Steps to set up:

  1. Create a .gitignore file in your root directory.
  2. Add patterns of files or folders to ignore.

Example:

*.log
node_modules/
.env
Enter fullscreen mode Exit fullscreen mode

No command is needed β€” Git will automatically skip tracking files that match the patterns.

Image description

Image description


πŸ“¦ Bonus: GitHub Repo

You can check out the repository related to this guide here:

πŸ‘‰ GitHub - 24MCR050


πŸ’‘ Final Thoughts

These Git commands may look simple, but mastering them gives you better control, cleaner workflows, and confidence when collaborating with teams. Whether you're debugging, exploring history, or working on features β€” Git's got your back.

If you liked this post, drop a ❀️ or comment your favorite Git command below!


πŸ§‘β€πŸ’» Written by Karthik Santhosh

Full-Stack Developer | React & Firebase | Open Source Learner

Heroku

Deliver your unique apps, your own way.

Heroku tackles the toil β€” patching and upgrading, 24/7 ops and security, build systems, failovers, and more. Stay focused on building great data-driven applications.

Learn More

Top comments (0)

Image of Stellar post

Check out Episode 1: How a Hackathon Project Became a Web3 Startup πŸš€

Ever wondered what it takes to build a web3 startup from scratch? In the Stellar Dev Diaries series, we follow the journey of a team of developers building on the Stellar Network as they go from hackathon win to getting funded and launching on mainnet.

Read more

πŸ‘‹ Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay