🚀 Essential Git Commands for Developers

🚀 Essential Git Commands for Developers

Master Git with this practical list of fundamental commands!

📌 Tracking Changes

🔹 git diff – View unstaged file differences.

🔹 git status – Check the state of your working directory.

🔹 git add <file> – Stage specific files.

🔹 git commit -a -m "message" – Commit all tracked changes with a message.

🔹 git commit --amend – Modify the last commit.

🔄 Working with Branches

🔹 git branch – List all branches.

🔹 git checkout -b <branch_name> – Create and switch to a new branch.

🔹 git checkout <branch_name> – Switch to an existing branch.

🔹 git merge <branch> – Merge one branch into another.

🔹 git rebase -i – Rewrite commit history interactively.

🔹 git branch -D <branch_name> – Force delete a branch.

📤 Syncing with Remote Repositories

🔹 git push origin <branch> – Push a branch to the remote repository.

🔹 git pull – Fetch and merge remote changes.

🔹 git clone <url> – Clone a remote repository locally.

🛠️ Reverting and Resetting Changes

🔹 git reset HEAD~1 – Undo the last commit while keeping changes.

🔹 git reset --hard – Reset to a previous commit, discarding all changes.

🔹 git revert <commit_id> – Create a new commit to reverse changes.

🔹 git cherry-pick <commit_id> – Apply a specific commit’s changes.

📂 Stash and Patches

🔹 git stash – Temporarily store uncommitted changes.

🔹 git stash pop – Reapply and remove stashed changes.

🔹 git format-patch -1 <commit_id> – Generate a patch from a commit.

🔹 git apply <patch_file> – Apply changes from a patch.

📜 Logs and History

🔹 git log --stat – Show commit logs with stats.

🔹 git show <commit_id> – Display details of a specific commit.

Yeahh ⚡ Now you have a quick reference guide to navigate Git with confidence! 🚀

Hyyan Abo Fakher

Lead Software Architect | Java & JavaScript Expert | Building What Others Build On

5mo

Great list of essential Git commands! I use quite a few of these daily. I’ve always preferred working with Git directly in the terminal rather than through IDE integrations or GUIs, just a habit from experience 😁

Like
Reply
Alisson Franca

Software Engineer | Full Stack Developer | Java | Spring Boot | Quarkus | React | AWS

5mo

Great list! 🚀 Mastering these Git commands is essential for any developer.

Like
Reply
Mauro Marins

.NET Software Engineer | Full Stack Developer | C# | .Net Framework | ASP.NET Core | Blazor | React | Azure | AWS

5mo

Interesting

Like
Reply
Gabriel Levindo

Android Developer | Mobile Software Engineer | Kotlin | Jetpack Compose | XML

5mo

Well done!!

Like
Reply

To view or add a comment, sign in

Others also viewed

Explore topics