DEV Community

Cover image for Beyond the Basics: 10 Git Commands to Level Up Your Development Game
Sakthivel R
Sakthivel R

Posted on

1

Beyond the Basics: 10 Git Commands to Level Up Your Development Game

🚀 Level Up with These Essential Git Commands

Introduction

Git is an indispensable tool for developers across all domains. As someone who works with both data engineering and MERN stack development, I've found these Git commands to be incredibly useful in my daily workflow. Let's explore them together!

Must-Know Git Commands

1. 🔍 git diff

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

Usage: 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 commit history.

Usage: 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/username/repository
Enter fullscreen mode Exit fullscreen mode

4. ⬇️ git pull

Purpose: Fetch and merge changes from the remote repository 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.

Usage: Great for debugging or understanding change history.

git blame filename.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 new-feature-branch
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.

Practical Workflow Examples

Here's how these commands fit into a typical development workflow:

  1. Start a new project:
   git clone https://github.com/username/project
Enter fullscreen mode Exit fullscreen mode
  1. Create a feature branch:
   git checkout -b new-feature
Enter fullscreen mode Exit fullscreen mode
  1. Make changes and check differences:
   # After editing files
   git diff
Enter fullscreen mode Exit fullscreen mode
  1. Commit your changes:
   git add .
   git commit -m "Add new feature"
Enter fullscreen mode Exit fullscreen mode
  1. Push to remote:
   git push origin new-feature
Enter fullscreen mode Exit fullscreen mode
  1. Keep your branch updated:
   git pull origin main
Enter fullscreen mode Exit fullscreen mode
  1. Investigate issues:
   git blame problematic-file.js
Enter fullscreen mode Exit fullscreen mode

Conclusion

These Git commands have become essential tools in my development workflow. Whether you're working on MERN applications or data engineering projects, mastering these Git techniques will dramatically improve your efficiency and collaboration capabilities.

What Git commands do you find most useful in your projects? Let me know in the comments!


Written by Sakthivel R

Data Engineer | MERN Stack Developer

Top comments (0)