blog
  • Blogs
    • Medium Articles
      • Linux
        • 40 Powerful Linux Networking Commands You Must Know.
        • These (Linux) VI Editor Shortcuts You Must Know
        • Bash/Linux Interview Questions for DevOps Engineers
        • Page 1
      • Git
        • 40 Powerful Git Commands Every Developer Should Know
        • 10 Git Best Practices That Every Developer Must Know
      • DevOps/SRE Interview Questions and Answers
        • Top DevOps/SRE Interview Questions and Answers on AWS VPC
        • Top 10 Common DevOps/SRE Interview Questions and Answers on Terraform Best Practices
        • Top 10 Common DevOps/SRE Interview Questions and Answers on Kubernetes Best Practices
        • Top 10 Common DevOps/SRE Interview Questions and Answers on Dockerfiles
        • Top 10 Common DevOps/SRE Interview Questions and Answers on Grafana
      • Installation
        • Docker Installation on Ubuntu 20/22
        • Install WireGuard VPN on Docker Compose
        • Install Redis on Docker Compose
        • Gravitee Docker Compose
      • Kubernetes Series 2025
        • Understanding Kubernetes: Part 1 -Control Plane
        • Understanding Kubernetes: Part 2 -Worker Node
        • Understanding Kubernetes: Part 3 -Pod
        • Understanding Kubernetes: Part 4-ReplicaSets
        • Understanding Kubernetes: Part 5 -Deployment
        • Understanding Kubernetes: Part 6 -DaemonSets
        • Understanding Kubernetes: Part 7 -StatefulSet
        • Understanding Kubernetes: Part 8 -ConfigMap
        • Understanding Kubernetes: Part 9 -Kubernetes Secret
        • Understanding Kubernetes: Part 10 -StorageClass
        • Understanding Kubernetes: Part 11 -Persistent Volume (PV)
        • Understanding Kubernetes: Part 12 -Persistent Volume Claim (PVC)
        • Understanding Kubernetes: Part 13 -Services
        • Understanding Kubernetes: Part 14 -ClusterIP Service
        • Understanding Kubernetes: Part 15 -NodePort Service
        • Understanding Kubernetes: Part 16 -Load Balancer Service
        • Understanding Kubernetes: Part 17 -Ingress
        • Understanding Kubernetes: Part 18 -Ingress Controller
        • Understanding Kubernetes: Part 19 -Headless Service
        • Understanding Kubernetes: Part 20-Network Policy
        • Understanding Kubernetes: Part 21 -CNI
        • Understanding Kubernetes: Part 22 Kubernetes Resource Requests & Limits
        • Understanding Kubernetes: Part 23 Node Selector
        • Understanding Kubernetes: Part 24 Taints and Tolerations
        • Understanding Kubernetes: Part 25 Affinity and Anti-Affinity
        • Understanding Kubernetes: Part 26 Preemption and Priority
        • Understanding Kubernetes: Part 27 Role and RoleBinding
        • Understanding Kubernetes: Part 28 ClusterRole and ClusterRoleBinding
        • Understanding Kubernetes: Part 29 Service Account
        • Understanding Kubernetes: Part 30 Horizontal Pod Autoscaler (HPA)
        • Understanding Kubernetes: Part 31 Vertical Pod Autoscaler (VPA)
        • Understanding Kubernetes: Part 33 Startup Probe
        • Understanding Kubernetes: Part 34 Liveness Probe
        • Understanding Kubernetes: Part 35 Readiness Probe
        • Understanding Kubernetes: Part 36 Container Network Interface (CNI)
        • Understanding Kubernetes: Part 37 Container Runtime Interface (CRI)
        • Understanding Kubernetes: Part 38 Container Storage Interface (CSI)
      • Cloudflare
        • Cloudflare Tunnel for Secure HTTP Routing
      • Nginx
        • Nginx use cases that every engineer must know
Powered by GitBook
On this page
  • Setup
  • Setup & Initialization
  • Stage & Snapshot
  • Branch & Merge
  • Inspect & Compare
  • Share & Update
  • Tracking Path Changes
  • Rewrite History
  • Ignoring Patterns
  • Temporary Commits
  • Why Learn Git?
  • Questions Answered
  • 🚀 Struggling with Kubernetes Concepts? We’ve Got You Covered!
  1. Blogs
  2. Medium Articles
  3. Git

40 Powerful Git Commands Every Developer Should Know

PreviousGitNext10 Git Best Practices That Every Developer Must Know

Last updated 5 months ago

Git is an indispensable 🛠️ for developers, enabling seamless 🤝, 📜 control, and code 🗂️. Whether you’re just starting out 🐣 or are an experienced developer 👨‍💻, mastering these Git commands will elevate your workflow 📈. Here’s a comprehensive guide to 40 powerful Git commands, categorized for clarity 🌟 and ease of use.

Setup

Configuring user information to be used across all local repositories:

  1. Set your name 📝:

  • git config --global user.name "[firstname lastname]"

Assign an identifiable name for version history credits 👤.

2. Set your email 📧:

  • git config --global user.email "[valid-email]"

Associate an email with each history marker 📜.

3. Enable colored output 🌈:

  • git config --global color.ui auto

Enhance readability with automatic command-line coloring 🎨.

Setup & Initialization

Setting up user information, initializing repositories, and cloning existing ones:

4. Initialize a Git repository 🏁:

  • git init

Turn an existing directory 📂 into a Git repository.

5. Clone a repository 🌐:

  • git clone [url]

Retrieve an entire repository from a remote location via its URL 🔗.

Stage & Snapshot

Work with snapshots 📸 and the staging area:

6. Check the status of your files 🔍:

  • git status

View modified files and staging status 🛠️.

7. Stage changes 📥:

  • git add [file]

Add the current state of a file 🗂️ to the next commit.

8. Unstage a file ⏪:

  • git reset [file]

Remove a file from the staging area but retain its changes 🔄.

9. See unstaged changes 👀:

  • git diff

Show changes that are not yet staged 📝.

10. See staged changes ✅:

  • git diff --staged

Show staged changes not yet committed 🔗.

11. Commit changes 📌:

  • git commit -m "[descriptive message]"

Save staged content as a snapshot 💾.

Branch & Merge

Isolate work in branches 🌿 and integrate changes 🔀:

12. List branches 🗒️:

  • git branch

Display all branches; the active branch is marked with * ⭐.

13. Create a new branch 🆕:

  • git branch [branch-name]

Create a new branch from the current commit 🌱.

14. Switch to another branch 🔄:

  • git checkout [branch-name]

Change to a different branch 🔄.

15. Merge branches ➕:

  • git merge [branch]

Combine the history of another branch into the current branch 🔗.

16. View commit history 🕰️:

  • git log

Show all commits in the current branch 📜.

Inspect & Compare

Examine logs, diffs, and object information 🔎:

17. View detailed commit history 📜:

  • git log

Show commit history for the active branch ⏳.

18. Compare branches ⚖️:

  • git diff branchB...branchA

Display the differences between two branches 🔍.

19. Follow file changes across renames 🛤️:

  • git log --follow [file]

Show all commits that modified a file, even if it was renamed 🔄.

20. Show object details 🧐:

  • git show [SHA]

Display information about a specific Git object 🔗.

Share & Update

Sync with remote repositories 🌐 and update local repositories 📥:

21. Add a remote repository 🔗:

  • git remote add [alias] [url]

Link a Git URL to your local repository 🌍.

22. Fetch updates 🔄:

  • git fetch [alias]

Retrieve updates from the remote repository 📥.

23. Merge updates ➕:

  • git merge [alias]/[branch]

Incorporate changes from a remote branch 🌟.

24. Push local changes 🚀:

  • git push [alias] [branch]

Send local branch commits to the remote repository 🌍.

25. Pull updates 🔄:

  • git pull

Fetch and merge updates from the remote branch 🔗.

Tracking Path Changes

Versioning file deletions 🗑️ and path changes 🛣️:

26. Delete a file and stage the change ❌:

  • git rm [file]

27. Move or rename a file ✏️:

  • git mv [existing-path] [new-path]

Change the path or name of a file and stage the change 🛠️.

28. Log path changes 📜:

  • git log --stat -M

Display commit logs with details of moved paths 🔍.

Rewrite History

Rewriting branches 🔄 and commits ✍️:

29. Reapply commits on another branch 🔄:

  • git rebase [branch]

30. Reset to a specific commit ⏪:

  • git reset --hard [commit]

Clear the staging area and working tree to match a specific commit 🚮.

Ignoring Patterns

Avoid committing unnecessary files 🗑️:

31. Set up a global ignore file 🚫:

  • git config --global core.excludesfile [file]

Use .gitignore files to exclude patterns ❌.

Temporary Commits

Store changes temporarily to switch branches or workspaces 🛠️:

32. Stash changes 📥:

  • git stash

33. List stashed changes 📜:

  • git stash list

34. Apply stashed changes 🔄:

  • git stash pop

35. Discard stash 🗑️:

  • git stash drop

Why Learn Git?

Git enhances team productivity 🤝, ensures safe code storage 💾, and enables better project management 📊.

Questions Answered

  • What are the most used Git commands? ❓

  • How do I resolve merge conflicts in Git? ⚔️

  • Why is Git essential for developers? 🌟

Keywords: Git commands 🛠️, Git tutorial 📚, Git guide 🚀, version control 🔄, Git branches 🌿, Git diff 📊, Git stash 📥.

Mastering Git is a journey 🛤️, but these commands will serve as a solid foundation for version control excellence 🏆. Start practicing today 🛠️ and take your Git skills to the next level 🚀!

🚀 Struggling with Kubernetes Concepts? We’ve Got You Covered!

This course simplifies everything with: ✅ Real-world examples to connect theory with practice. 🛠️ Hands-on labs to build confidence through action. 📚 Clear explanations that make even complex topics easy to understand.

and take the first step toward becoming a Kubernetes pro! 🌟

Thank you!

Be sure to clap and follow the writer ️👏

👉 You won’t find a better way to master Kubernetes!

·

DevOps | SRE | Carrers | Cloud | AI | Software Automation

Enroll Now
https://cloudops0.gumroad.com/l/k8s
Git
Github
Source Code
Developer
DevOps
https://techwithpatil.com
Written by techwithpatil
150 Followers
259 Following
Git Commands