Git Worktrees Tutorial #5 - Worktrees in Agentic Coding Workflows

The Net Ninja · Beginner ·🛠️ AI Tools & Apps ·3mo ago

Key Takeaways

The video tutorial covers using Git worktrees in agentic coding workflows, allowing for multiple branch checkouts in separate directories. It's part of a larger Git and GitHub masterclass series by The Net Ninja.

Full Transcript

Okay, then my friends, so we've learned about Git work trees now and how they can be useful in a regular development workflow because they allow you to easily switch between multiple branches and work on different things at once. And because of that, they've become increasingly popular with agentic coding workflows as well because now instead of getting Claude code or Gemini CLI or whatever else working on just a single feature at time, by using work trees, you can work on multiple features at once or iterate on the same feature in two different sessions to see which implementation you prefer. So, I've already created another work tree in this project called feature XYZ and I've got two terminal windows open as well. One for the feature ABC work tree and one inside the feature XYZ work tree. And what I might do is start in one of these sessions to create some new feature. For example, I could say here that I want it to flesh out an about page, which is a very simple task, but it serves as an example. So then, let's hit enter to send this prompt. And now while it works, instead of just sitting around waiting, I can switch to my other work tree and work on another feature at the same time. Now, I can either do that manually or use another Claude session to let the coding agent work on something else, which is what I'm going to do right now. So, I'll ask it to make a contact page with a contact form in it and it can go ahead and work on that feature at the same time that Claude is working on something else up here. And that saves a little bit of time, right? Rather than sit around waiting for one task to complete before we start another, um I can just get them both running at the same time. And I know that these two features were really basic and they'll only take Claude about a minute or so to complete, but sometimes when I'm working on features, it can be spinning around for 7 or 8 minutes before it's finished. And in that time, I can either just sit around twiddling my thumbs, scroll YouTube, which is always fun, or I can spin up a new task in a different work tree. Now, I'm not one of these kind of power users, as they're called, who spins up five or six different sessions at once because I think for me that would become a little complex to manage and it would probably result in a fair few conflicts which I'd then have to resolve manually. Uh so I think for me two is enough, three in a push when I really want to get things done. And uh the process beyond this agentic workflow is pretty much the same as before. We can review the code locally, make a commit, push up to GitHub, and merge. Now something else I occasionally do is create some kind of custom slash command in Claude Code which instructs the agent to autonomously add a new work tree and branch whenever it begins a new feature. And that way I don't even need to worry about manually creating them myself. I can just run that custom slash command along with a feature spec and Claude Code will do it for me. If that's something you're interested in, do let me know. And also if you want to learn about Claude Code in more depth and how I like to set up a spec-first agentic workflow, then definitely check out my Claude Code masterclass on netninja.dev. It goes into a lot of detail about feature development uh utilizing custom commands, sub-agents, MCP servers, and Git and GitHub as well. So I'll leave the link to that course down below the video. Anyway, hopefully now you can see the benefit of using Git work trees both for agentic workflows and just regular development workflows as well when you're not using coding agents. And that's pretty much the end of this small series. So I really hope you enjoyed it and hopefully now you know what Git work trees are. If you did like it, please don't forget to share, subscribe, and like. That really helps a lot and I'm going to see you all in the next one. >> [music] [music] [music] >> Oh. Oh. Oh. Oh. Oh. Oh. Oh.

Original Description

In this series, you’ll learn how to use Git worktrees, a feature that lets you check out multiple branches at the same time in separate working directories. 🍿👇 Get the FULL Git & GitHub Masterclass: https://netninja.dev/p/git-github-masterclass 🍿👇 Get the FULL Claude Code Masterclass: https://netninja.dev/p/claude-code-masterclass 🔥👇 Get access to ALL Masterclasss & premium courses with Net Ninja Pro: https://netninja.dev/p/net-ninja-pro/#prosignup Starter Project: https://github.com/iamshaunjp/portfolio-worktrees
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Net Ninja · Net Ninja · 0 of 60

← Previous Next →
1 Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
2 Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
3 Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
4 GraphQL Tutorial #1 - Introduction to GraphQL
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
5 GraphQL Tutorial #2 - A Birdseye View of GraphQL
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
6 GraphQL Tutorial #3 - Project (stack) Overview
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
7 GraphQL Tutorial #4 - Making Queries (front-end preview)
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
8 GraphQL Tutorial #5 - Express App Setup
GraphQL Tutorial #5 - Express App Setup
Net Ninja
9 GraphQL Tutorial #6 - Setting up GraphQL
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
10 GraphQL Tutorial #7 - GraphQL Schema
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
11 GraphQL Tutorial #8 - Root Query
GraphQL Tutorial #8 - Root Query
Net Ninja
12 GraphQL Tutorial #9 - The Resolve Function
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
13 GraphQL Tutorial #10 - Testing Queries in Graphiql
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
14 GraphQL Tutorial #11 - GraphQL ID Type
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
15 GraphQL Tutorial #12 - Author Type
GraphQL Tutorial #12 - Author Type
Net Ninja
16 GraphQL Tutorial #13 - Type Relations
GraphQL Tutorial #13 - Type Relations
Net Ninja
17 GraphQL Tutorial #14 - GraphQL Lists
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
18 GraphQL Tutorial #15 - More on Root Queries
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
19 GraphQL Tutorial #16 - Connecting to mLab
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
20 GraphQL Tutorial #17 - Mongoose Models
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
21 GraphQL Tutorial #18 - Mutations
GraphQL Tutorial #18 - Mutations
Net Ninja
22 GraphQL Tutorial #19 - More on Mutations
GraphQL Tutorial #19 - More on Mutations
Net Ninja
23 GraphQL Tutorial #20 - Updating the Resolve Functions
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
24 GraphQL Tutorial #21 - GraphQL NonNull
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
25 GraphQL Tutorial #22 - Adding a Front-end
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
26 GraphQL Tutorial #23 - Create React App
GraphQL Tutorial #23 - Create React App
Net Ninja
27 GraphQL Tutorial #24 - Book List Component
GraphQL Tutorial #24 - Book List Component
Net Ninja
28 GraphQL Tutorial #25 - Apollo Client Setup
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
29 GraphQL Tutorial #26 - Making Queries from React
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
30 GraphQL Tutorial #27 - Rendering Data in a Component
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
31 GraphQL Tutorial #28 - Add Book Component
GraphQL Tutorial #28 - Add Book Component
Net Ninja
32 GraphQL Tutorial #29 - External Query File
GraphQL Tutorial #29 - External Query File
Net Ninja
33 GraphQL Tutorial #30 - Updating Component State
GraphQL Tutorial #30 - Updating Component State
Net Ninja
34 GraphQL Tutorial #31 - Composing Queries
GraphQL Tutorial #31 - Composing Queries
Net Ninja
35 GraphQL Tutorial #32 - query variables
GraphQL Tutorial #32 - query variables
Net Ninja
36 GraphQL Tutorial #33 - Re-fetching Queries
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
37 GraphQL Tutorial #34 - Book Details Component
GraphQL Tutorial #34 - Book Details Component
Net Ninja
38 GraphQL Tutorial #36 - Styling the App
GraphQL Tutorial #36 - Styling the App
Net Ninja
39 GraphQL Tutorial #35 - Making a Single Query
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
40 Build Apps with Vue & Firebase - Udemy Course
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
41 Updated Vue & Firebase Course (Udemy)
Updated Vue & Firebase Course (Udemy)
Net Ninja
42 Vue & Firebase Real-time Chat (Preview) #1 - Intro
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
43 Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
44 Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
45 Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
46 Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
47 Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
48 Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
49 Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
50 Object Oriented JavaScript Tutorial #1 - Introduction
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
51 Object Oriented JavaScript Tutorial #2 - Object Literals
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
52 Object Oriented JavaScript Tutorial #3 - Updating Properties
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
53 Object Oriented JavaScript Tutorial #4 - Classes
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
54 Object Oriented JavaScript Tutorial #5  - Class Constructors
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
55 Object Oriented JavaScript Tutorial #6 - Class Methods
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
56 Object Oriented JavaScript Tutorial #7 - Method Chaining
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
57 Object Oriented JavaScript Tutorial #8 - Class Inheritance
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
58 Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
59 Object Oriented JavaScript Tutorial #10 - Prototype
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
60 Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja

This tutorial teaches how to use Git worktrees for managing multiple branches in separate directories, enhancing agentic coding workflows. It's crucial for efficient version control and collaborative coding. By mastering Git worktrees, developers can streamline their workflow and improve productivity.

Key Takeaways
  1. Create a new Git repository
  2. Initialize a worktree
  3. Checkout a new branch in the worktree
  4. Manage multiple branches simultaneously
  5. Merge changes between branches
💡 Git worktrees allow developers to work on multiple branches simultaneously, improving workflow efficiency and reducing conflicts.

Related AI Lessons

Up next
I Asked ChatGPT to Apply to 500 Jobs (8 Interviews in 48 Hours)
Sabrina Ramonov 🍄
Watch →