Ever had that moment where you're deep in a feature, everything clicking, and then ping "Can you fix this bug real quick?" You stash your changes. Switch branches. Wait for dependencies. Fix the bug. Switch back. Try to remember where you were. That mental context? Gone. 𝗚𝗶𝘁 𝗪𝗼𝗿𝗸𝘁𝗿𝗲𝗲𝘀 + 𝗖𝗹𝗮𝘂𝗱𝗲 𝗖𝗼𝗱𝗲 𝘀𝗼𝗹𝘃𝗲𝗱 𝘁𝗵𝗶𝘀 𝗳𝗼𝗿 𝗺𝗲. What are worktrees? Normally you switch branches inside one folder. A worktree checks out a different branch in a separate folder sharing the same Git history. No cloning. No duplicating. 𝘨𝘪𝘵 𝘸𝘰𝘳𝘬𝘵𝘳𝘦𝘦 𝘢𝘥𝘥 ../𝘩𝘰𝘵𝘧𝘪𝘹 𝘮𝘢𝘪𝘯 That's it. A second working directory, ready in seconds. Why this matters with Claude Code: Run a separate Claude Code session in each worktree. Each session stays scoped to its own task its own files, its own branch, its own context. Worktree 1: Claude helping you build a feature Worktree 2: Claude fixing review comments on a different PR Worktree 3: Claude writing tests while CI runs on the other two No crossed wires. No "wrong branch" suggestions. Each session is laser-focused. How I use it daily: I keep 3 reusable worktrees. When a new task comes in, I reset one to main, create a branch, run claude, and start working in under 10 seconds. My other tasks stay exactly where I left them. No stashing. No dependency reinstalls. No lost context. Quick setup: 𝘨𝘪𝘵 𝘸𝘰𝘳𝘬𝘵𝘳𝘦𝘦 𝘢𝘥𝘥 ../𝘵𝘢𝘴𝘬-2 𝘮𝘢𝘪𝘯 𝘤𝘥 ../𝘵𝘢𝘴𝘬-2 claude When done: 𝘨𝘪𝘵 𝘸𝘰𝘳𝘬𝘵𝘳𝘦𝘦 𝘳𝘦𝘮𝘰𝘷𝘦 ../𝘵𝘢𝘴𝘬-2 Tips: Keep worktrees around. Reset to main instead of recreating. Worktrees share Git history - commits and branches are visible everywhere. Perfect for stacked PRs - one worktree per PR, one Claude session per piece. Pro tip: Ask Claude Code to "create 3 worktrees for me" and it will set them all up within seconds. You don't even need to remember the commands. #GitWorktrees #ClaudeCode #DeveloperProductivity #AIAssistedCoding
Git Worktrees Simplify Developer Workflow with Claude Code
More Relevant Posts
-
👨💻 Dev A: “Bro… I have 3 tasks: a bug fix, a new feature, and a hotfix. I keep switching branches and it’s slowing me down 😩” 👨💻 Dev B: “Why are you suffering? Just use git worktree 😎” 👨💻 Dev A: “Worktree? Sounds like extra work.” 👨💻 Dev B: “Nope. It lets you checkout multiple branches at the same time in different folders.” 🚀 Real Problem • Have multiple tasks • Need different branches • Hate constant git checkout switching 🌳 Solution: Git Worktree 👉 Create separate working directories for each branch: git worktree add ../feature-task feature-branch git worktree add ../bugfix-task bugfix-branch git worktree add ../hotfix-task hotfix-branch Now your folder looks like: project/ feature-task/ bugfix-task/ hotfix-task/ 🔥 How You Work Now •Open each folder in separate VS Code window •Work on all tasks in parallel •No branch switching, no stash drama 🧠 Key Commands Remove a worktree: git worktree remove ../feature-task List all worktrees: git worktree list ⸻ 👨💻 Dev A: “So… I can code 3 tasks at once without touching checkout?” 👨💻 Dev B: “Exactly. Welcome to peaceful development 😌” If you’re multitasking across branches, git worktree is a game changer. #Git #DeveloperTips #Productivity #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Today I learned: How to revert only specific files from a bad Git commit Earlier today, I made a mistake while working on a feature branch — I accidentally overwrote 31 important "workflow.json" files across two folders. The tricky part? I also had valid changes in the same branch that I needed to keep. A normal "git revert" would undo everything - good and bad. That’s when I discovered a much cleaner approach: a surgical revert that restores only the files you choose. Here’s the simple workflow I followed 👇 🔍 1. Find commits that touched the files git log --oneline -- 'path/to/folder/**/file.json' This filters history so you can quickly spot where things went wrong. 👀 2. Peek at file content from any commit git show <commit-id>:path/to/file.json No checkout needed — just inspect the file as it existed in the past. 📂 3. List exactly which files a bad commit changed git diff-tree --no-commit-id --name-only -r <bad-commit> -- 'path/**/*.json' This gave me a precise list of the 31 affected files. ♻️ 4. The magic command — restore only those files git checkout <good-commit-or-branch> -- file1 file2 file3 ... This pulls back only the selected files — everything else stays untouched. ✨ ✅ 5. Verify before committing git status --short git diff --cached I used to worry about “messing up Git,” but moments like this made me realize - Git is actually very forgiving when you know the right tools. If you're learning Git, this is a skill that will save you hours someday. #Git #SoftwareEngineering #LearningInPublic #DeveloperTips #VersionControl
To view or add a comment, sign in
-
-
Stop the "Stash & Switch" madness. 🛑 We’ve all been there: You’re deep in a feature, your workspace is a mess of half-finished logic, and suddenly... a critical bug hits production. Most devs reach for git stash. Some make a messy "WIP" commit. But there’s a better way that most people ignore: Git Worktree. Instead of flipping a single folder between branches, Git Worktree lets you "check out" multiple branches into separate folders simultaneously, all linked to the same local repo. Why is this a game-changer? ✅ Zero Context Switching: Keep your feature code open in one VS Code window and your hotfix in another. No stashing required. ✅ Parallel Testing: Run a heavy test suite or build process on one branch while you keep coding on the other. ✅ Code Reviews: Need to test a teammate's PR? Open it in a new worktree without touching your current progress. ✅ No More npm install Loops: If branches have different dependencies, worktrees keep their respective node_modules intact. No more re-installing every time you switch. The Magic Command: git worktree add ../hotfix-folder hotfix-branch It’s one of those "once you know it, you can't go back" tools. Are you still stashing, or have you made the switch to Worktrees? Let’s hear your workflow hacks in the comments! 👇 #Git #WebDevelopment #SoftwareEngineering #DevOps #ProgrammingTips #Efficiency
To view or add a comment, sign in
-
Most devs know 5 git commands. Then production diverges at 3 a.m. and those 5 aren't enough. Here are 10 I actually reach for every week. 1. git reflog Your undo button. rebase, reset, force-push — reflog remembers. 2. git log --oneline --graph --all See your branch topology without opening a GUI. 3. git commit --amend --no-edit Fix the last commit. Keep the message. 4. git stash push -m "wip: auth on /users" Stash with context. Future You will thank you. 5. git blame -L 42,58 services/auth.py Blame a line range, not the whole file. 6. git rebase -i HEAD~5 Clean your PR history before review, not during it. 7. git cherry-pick <sha> Port one commit across branches. No full-branch merge. 8. git worktree add ../hotfix origin/main Two branches checked out at once. Zero context switch. 9. git bisect start HEAD v1.2 Binary-search your way to the commit that broke prod. 10. git push --force-with-lease The safe force push. Pair with --force-if-includes on git 2.30+. None of these are niche. They are the difference between a 10-minute fix and a 2-hour war room. Save this before your next git emergency. Which one saved you first — and what was the incident? One command, one sentence. #Git #SoftwareEngineering #DeveloperTips #CodingTips
To view or add a comment, sign in
-
Essential Git Commands Every Developer Should Know (Practical Guide) Git is not just about add, commit, and push. Knowing the right commands helps you manage code, collaborate safely, and recover quickly from mistakes. ⸻ 📁 Repository Setup git init – Initialize a new repository git clone <repo_url> – Clone existing repository ⸻ 📌 Tracking Changes git status – Check current changes git add <file> / git add . – Stage changes ⸻ 💾 Committing git commit -m "message" – Save changes git commit --amend – Modify last commit ⸻ 🌿 Branching git branch – List branches git checkout -b <branch> – Create & switch git switch <branch> – Switch branch ⸻ 🔀 Merge / Rebase git merge <branch> – Merge branches git rebase <branch> – Clean commit history ⸻ 🚀 Remote git pull – Get latest changes git fetch – Fetch without merging git push origin <branch> – Push code ⸻ ⏪ Undo git restore <file> – Discard changes git reset <file> – Unstage git revert <commit> – Safe undo (recommended) ⸻ 🔍 History git log --oneline – View commits git diff – Check differences ⸻ 📦 Stash git stash – Save work temporarily git stash pop – Restore work ⸻ 🧩 Practical Scenario (Hotfix) git stash → git checkout main → git pull → git checkout -b hotfix/issue → fix → commit → git push ⸻ Key Takeaways • Prefer fetch before pull • Use revert instead of reset in shared branches • Keep commits small and meaningful • Always verify using status before pushing ⸻ Mastering Git is about using the right command at the right time. #Git #VersionControl #SoftwareEngineering #Developers #DevOps
To view or add a comment, sign in
-
Ever needed to switch branches… but your code isn’t ready to commit? 👀 That’s where git stash helps. It saves your current work (staged + modified tracked changes) and resets everything back to HEAD, so you can safely switch branches without committing incomplete code. Your stashes are stored like a stack (stash@{0} is the latest), and you can reuse them anytime. By default, only tracked files are saved: Add untracked files → git stash push -u Add ignored files → git stash push -a When you’re ready to continue: git stash apply → bring changes back (keep stash) git stash pop → bring changes + remove stash Need a specific one? git stash apply stash@{N} Want your staged changes back too? git stash apply --index git stash pop --index Manage everything easily: Save → git stash push -m "message" View → git stash list Inspect → git stash show -p stash@{N} Delete → git stash drop stash@{N} or git stash clear Think of it as putting your work on pause without losing a thing. 👉 Follow for more practical dev tips! #Git #GitHub #WebDevelopment #DevTips #Developers #Syncfusion
To view or add a comment, sign in
-
-
Cloning the Repo Right: My Day 1 Setup Workflow Yesterday I got added to a new project by my lead. Before touching any code, I focused on setup first. I created a local folder, opened terminal in that folder, and cloned the repo using HTTPS: git clone https://lnkd.in/dABQE_CS cd repo-name Then I asked my lead 3 things: - Which branch is the main/live branch? - Where should my code be merged? - What branch naming convention should I follow? Once clear, I created my feature branch from main and started working: git checkout -b feature/your-branch-name Before pushing, I sync with latest main to reduce merge conflicts: git stash -u git checkout main git pull origin main git checkout feature/your-branch-name git stash pop (Resolve conflicts if any) git push origin feature/your-branch-name This small habit has saved me from last-minute PR issues multiple times. How do you handle Day 1 setup when you join a new repo? #git #github #frontenddeveloper #webdevelopment #devlife
To view or add a comment, sign in
-
Git Merge vs Git Rebase — do you know when to use each? 🔀 Both commands integrate changes from one branch into another, but they produce very different histories. Git Merge creates a merge commit that ties two branches together while preserving every commit exactly as it happened. It's safe for shared branches and gives you a complete picture of your project history. Git Rebase replays your branch's commits on top of another, rewriting history to produce a clean, linear line. Think of it as saying "pretend I always branched from this point." When to merge: ✅ Integrating a feature branch into main/master ✅ Working on a shared branch with teammates ✅ You want full history preserved When to rebase: ✅ Updating a feature branch with the latest changes before merging ✅ Cleaning up a messy local commit history ✅ You want a readable, linear project history ⚠️ One golden rule: never rebase a branch other developers are actively working on — it rewrites commit hashes and will break their local copies. We've written a full visual walkthrough with step-by-step screenshots using LithiumGit — showing exactly what happens to your commit graph in each scenario. 🔗 Read the full guide: https://lnkd.in/gdvYueJ5
To view or add a comment, sign in
-
𝟱 𝗮𝗱𝘃𝗮𝗻𝗰𝗲𝗱 𝗚𝗶𝘁 𝗰𝗼𝗺𝗺𝗮𝗻𝗱𝘀 𝗜 𝘄𝗶𝘀𝗵 𝗜 𝗹𝗲𝗮𝗿𝗻𝗲𝗱 𝗲𝗮𝗿𝗹𝗶𝗲𝗿. Most engineers know add, commit, push. These 5 are the ones that actually save you when things go sideways. 𝟭. 𝗴𝗶𝘁 𝗿𝗲𝗳𝗹𝗼𝗴 — 𝘆𝗼𝘂𝗿 𝘀𝗮𝗳𝗲𝘁𝘆 𝗻𝗲𝘁 Accidentally did git reset --hard? Reflog keeps a record of every HEAD move for ~90 days. git reset --hard HEAD@{1} and you're back. 𝘕𝘰𝘵𝘩𝘪𝘯𝘨 𝘪𝘴 𝘵𝘳𝘶𝘭𝘺 𝘭𝘰𝘴𝘵. 𝟮. 𝗴𝗶𝘁 𝗿𝗲𝗯𝗮𝘀𝗲 -𝗶 — 𝗰𝗹𝗲𝗮𝗻 𝗵𝗶𝘀𝘁𝗼𝗿𝘆 𝗯𝗲𝗳𝗼𝗿𝗲 𝗮 𝗣𝗥 10 "WIP" commits, 3 typo fixes, 2 "oops" commits. Embarrassing. git rebase -i HEAD~10 — squash, reword, or drop commits before anyone reviews. 𝟯. 𝗴𝗶𝘁 𝗯𝗶𝘀𝗲𝗰𝘁 — 𝗯𝗶𝗻𝗮𝗿𝘆 𝘀𝗲𝗮𝗿𝗰𝗵 𝗳𝗼𝗿 𝗮 𝗯𝘂𝗴 500 commits. Something broke. No idea when. git bisect start → mark good and bad commits → Git finds the culprit in ~9 steps. Fully automated: git bisect run pytest tests/ 𝟰. 𝗴𝗶𝘁 𝘄𝗼𝗿𝗸𝘁𝗿𝗲𝗲 — 𝘁𝘄𝗼 𝗯𝗿𝗮𝗻𝗰𝗵𝗲𝘀, 𝗻𝗼 𝘀𝘁𝗮𝘀𝗵𝗶𝗻𝗴 git worktree add ../hotfix hotfix/auth Full second working copy of the same repo, different branch. No stash, no context-switch chaos. 𝟱. 𝗴𝗶𝘁 𝗰𝗵𝗲𝗿𝗿𝘆-𝗽𝗶𝗰𝗸 --𝗻𝗼-𝗰𝗼𝗺𝗺𝗶𝘁 Apply one commit from another branch — but inspect it before it lands. git cherry-pick --no-commit a3f9b2c → review with git diff --staged → commit when satisfied. 𝗴𝗶𝘁 𝗶𝘀 𝗻𝗼𝘁 𝗮 𝘀𝗮𝘃𝗲 𝗯𝘂𝘁𝘁𝗼𝗻. 𝗜𝘁'𝘀 𝗮 𝘁𝗶𝗺𝗲 𝗺𝗮𝗰𝗵𝗶𝗻𝗲. Learn the power commands and you'll never fear a bad commit again. #git #devtools #softwaredevelopment #versioncontrol #engineeringlife
To view or add a comment, sign in
-
If you don’t know these Git & GitHub commands, you’re making development harder than it needs to be. → git init — start a repository → git add . — stage all changes → git commit -m "msg" — save changes → git status — check file state → git log --oneline — view history → git branch — list branches → git checkout -b <branch> — create + switch → git merge <branch> — merge changes → git remote add origin <url> — connect repo → git push origin — upload code → git pull origin — get updates → git clone <url> — copy repo → git revert HEAD — undo safely → git reset <id> — go back → git commit --amend — fix last commit ─────────────────── These are not “extra” commands. This is your daily workflow. And yes — this is exactly what gets asked in interviews. This PDF explains everything clearly: • How Git tracks changes • Staging → Commit → History • Branching & merging • Working with GitHub • Undoing mistakes properly Now the part that actually helps: • Don’t memorize — use Git daily • Understand reset vs revert (very important) • Write meaningful commit messages • Practice branching on small projects • Learn by breaking things & fixing them One simple test: If you can explain your Git workflow step-by-step… you’re already ahead of most candidates. Use this like a quick revision: Open → scan → recall → apply That’s all it takes. Save this — this is your 10-minute Git revision before interviews.
To view or add a comment, sign in
More from this author
Explore related topics
- Best Practices for Using Claude Code
- How to Use Git for IT Professionals
- How to Boost Productivity With Developer Agents
- How to Stay Focused During Long Coding Sessions
- Tips for Improving Developer Workflows
- Claude's Contribution to Streamlining Workflows
- How Claude Code Transforms Team Workflows
- Best Use Cases for Claude AI
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
This can make one super productive 😊