📚 Git Basics & Remote Workflow
🔗 Remotes
View remotes:
git remote -v
🔄 Fetching
Fetch updates from a remote without changing your local branch:
git fetch <remote>
👉 Safe — it just downloads remote branches.
👀 Checking Remote Branches
List all branches from all remotes:
git branch -r
Inspect what branches a specific remote has:
git ls-remote --heads <remote>
🟢 Checking Out a Remote Branch
To look at code from a remote branch without merging:
git checkout <remote>/<branch>
👉 This puts you in detached HEAD (safe for viewing).
Go back to your working branch:
git checkout <branch>
🌱 Creating a Local Branch from Remote
If you need to work on top of the client’s branch:
git checkout -b <new-local-branch> <remote>/<branch>
🔎 Comparing Branches
Compare your current branch with a remote branch:
git diff <remote>/<branch>
Show only changed files:
git diff --stat <remote>/<branch>
Compare commits:
git log HEAD..<remote>/<branch> --oneline
git log <remote>/<branch>..HEAD --oneline
🔀 Merging or Rebasing
Merge remote branch into your branch:
git merge <remote>/<branch>
Rebase onto remote branch (linear history):
git rebase <remote>/<branch>
🚫 Undoing Remote Commits (Keep Locally)
If you need to remove commits from remote but keep them locally:
git push origin <older-commit-hash>:<branch> --force-with-lease
👉 Moves the remote branch pointer back.
🔥 Tips
✅ Quick Workflow Cheat-Sheet
Would you like me to format this as a Markdown doc (so you can paste into Notion/Confluence) or as a shorter Slack message for quick sharing?