Master 50+ Essential Git Commands for Efficient Team Collaboration

If you don't know these 50+ Git commands, you're slowing your team down. Here are 50+ commands you must already have in your toolkit: ───────────────────── → git init — Start a new local repo → git clone — Copy a remote repo locally → git status — Check working directory state → git add — Stage a specific file → git add . — Stage all changes → git commit -m "msg" — Commit with a message → git commit -a -m "msg" — Stage + commit tracked files → git commit --amend — Edit the last commit → git log — View commit history → git log --oneline — Compact commit history → git log --stat — Commit history with file stats → git show <commit_id> — Details of a specific commit → git branch — List all branches → git branch — Create a new branch → git branch -D — Force delete a branch → git branch -m — Rename a branch → git checkout — Switch to a branch → git checkout -b — Create + switch to new branch → git checkout — Switch to a specific commit → git switch — Modern way to switch branches → git switch -c — Create + switch (modern syntax) → git merge — Merge a branch into current → git merge --no-ff — Merge with a merge commit always → git rebase — Rebase current branch onto another → git rebase -i HEAD~n — Interactive rebase (rewrite history) → git cherry-pick <commit_id> — Apply a specific commit to current branch → git remote -v — List remote connections → git remote add origin — Add a remote repo → git push origin — Push branch to remote → git push -u origin — Push + set upstream → git push --force — Force push (use carefully) → git pull — Fetch + merge remote changes → git fetch — Fetch without merging → git branch --set-upstream-to <remote/branch> — Set upstream tracking branch → git reset HEAD~1 — Undo last commit, keep changes → git reset --soft HEAD^ — Undo last commit, stage changes → git reset --hard — Reset everything, erase all changes → git revert <commit_id> — Create new commit that undoes a commit → git restore — Discard unstaged changes in a file → git clean -fd — Remove untracked files + directories → git diff — Show unstaged changes → git diff --staged — Show staged changes → git diff — Compare two branches → git blame — See who changed each line → git shortlog — Summarize commits by author → git stash — Stash current changes → git stash pop — Apply + remove latest stash → git stash list — List all stashes → git stash apply stash@{n} — Apply a specific stash → git stash drop — Delete the latest stash → git stash clear — Delete all stashes → git config --global user.name "Name" — Set global username → git config --global user.email "email" — Set global email → git alias — Create shortcuts for commands 𝑾𝒉𝒂𝒕𝒔𝑨𝒑𝒑 𝒈𝒓𝒐𝒖𝒑 𝒇𝒐𝒓 𝒕𝒉𝒆 𝒍𝒂𝒕𝒆𝒔𝒕 𝑼𝒑𝒅𝒂𝒕𝒆: https://lnkd.in/dtq-J2V5 #Git #GitHub #GitCommands #VersionControl #SoftwareDevelopment #BackendDevelopment #Java #Programming #Developer #DevCommunity #CodingInterview

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories