< Back to Blog

Version Control in the Age of AI: The Complete Guide

With the rise of AI coding assistants like Claude Code and Gemini CLI, our development workflows are changing at a rapid pace. These tools can be incredibly powerful, but they also introduce new challenges. How do we maintain a clean, understandable, and efficient version control history when a significant portion of our code is generated by AI?

This article will provide a practical guide for developers to effectively use Git and version control in the age of AI. Whether you're a "vibe-coder" or a seasoned software engineer or web developer, we believe this guide can teach you something valuable to apply to your daily workflow.

We will first cover the fundamentals of Git and then explore some more advanced techniques, such as Git Worktrees, to help you maintain control of your project's advancements and keep your version control history clean and organized.

Along the way, we will also explain how Tower, our Git client, can assist you!

The Importance of Creating Snapshots of Your Project

When working with AI-generated code, it's easy to get carried away and end up with large, monolithic changes. This is where the discipline of creating frequent, small commits becomes your best friend.

Think of each commit as a snapshot of your work — a safety net that you can always go back to. If an AI-generated change introduces a bug or takes you down the wrong path, you can easily revert to a previous state. Tiny, atomic commits make it much easier to pinpoint where things went wrong.

In the upcoming chapters, we will explore a variety of techniques — both basic and advanced — that will help you keep track of your code developments.

The Fundamentals of Git

Let's start by revisiting some core Git best practices that are more important than ever in the age of AI: crafting effective commit messages and efficiently managing branches.

☝️ If you're just getting started with Git, we recommend exploring our Learn section, where you'll find a variety of free resources to help you become confident with version control, including ebooks and videos.

Crafting the Perfect Commit Message

A well-crafted commit message is a love letter to your future self and your teammates. When working with AI, it's crucial to explain the "why" behind a change, not just the "what". The AI can generate the code, but it can't (yet) understand the business context or the problem you're trying to solve.

A good commit message should be clear, concise, and descriptive. It should explain the intent behind the change and any trade-offs that were made.

This is such an important topic that we have dedicated an entire article to it!

How Tower Can Help 🔥

Tower has lots of features to help you create better commits. Here are some tips!

  1. While writing a commit in the "Working Copy" view, press / to easily reference files, commits, or even insert an emoji (Tower supports Gitmoji). If you have a service account like GitHub connected, you can also easily address an issue.
Composing Commits in Tower


  1. If your team follows specific guidelines, adhering to commit templates will make a lot of sense. The tip mentioned above allows you to follow a commit template, and you can also click the button next to the character counter to insert a template. To create, edit, or delete commit templates, visit the "Templates" tab in the Settings.
Managing Commit Templates in Tower

Branching Strategies

Feature branches are the cornerstone of a healthy Git workflow. They allow you to work on new features or bug fixes in isolation without affecting the main branch. This is especially important when experimenting with AI-generated code.

Create a new branch for each new task, and only merge it back into the main branch when you're confident that the code is working as expected.

How Tower Can Help 🔥

With its visualization capabilities, Tower lets you quickly explore any branch by viewing the list of branches in the sidebar. But a lot more can be achieved here!

  1. Tower is aware of the parent branch; therefore, if the main branch has received an update, you can quickly update your feature branch to incorporate the latest changes.
Tower's
Tower's "Update Branch" feature


  1. The "Fork Point" feature in Tower will display the precise commit at which a branch split from its parent. Commits that occurred before this divergence will appear grayed out.
Tower's
Tower's "Fork Point"


  1. Our newly released Tower Workflows feature allows you to easily create new branches and merge/clean them up when you're finished. It was designed with flexibility in mind, enabling you to customize how the feature works to suit your needs.

Advanced Git Techniques for AI-Powered Development

Now that we've covered the basics, let's explore some advanced Git techniques that are particularly well-suited for working with AI.

Staging Chunks and Lines for Granular Commits

AI-generated code often comes in large blocks. Instead of committing the entire block at once, it's a good practice to review the changes and stage them in smaller, logical chunks.

How Tower Can Help 🔥

Tower's "Changeset" view allows you to do just that. Instead of typing git add -p in the command line, you can stage individual lines or chunks of code with a single click.

This gives you granular control over what goes into each commit, helping you create those small, atomic commits we talked about earlier.

Tower's single-line staging feature

Interactive Rebase for a Clean History

AI assistants can sometimes be a bit "chatty," generating a lot of small, incremental changes. While this is great for experimentation, it can lead to a cluttered commit history.

This is where interactive rebase comes into play. Interactive rebase allows you to rewrite your commit history before merging a branch. You can reorder, squash, and edit commits to create a clean and logical history.

Before pushing your changes to the remote repository, it is always advisable to take some time to organize your commits — for your future self and your team!

Squashing is great if you prefer to move forward carefully in small steps. You can continuously add small commits labeled as "WIP" (Work in Progress) and then combine them all into a single commit when the feature is complete.

How Tower Can Help 🔥

Instead of using the command line (git rebase -i), Tower makes interactive rebase as easy as dragging and dropping:

  1. You can reorder commits by dragging them up or down in the "History" view. Tower's drag and drop feature is very capable!
  2. You can edit commit messages or the content of the commits by right-clicking a commit and selecting "Edit commit message of [COMMIT]" or "Edit [COMMIT]," respectively.

If you choose the latter option, Tower will check out that commit and allow you to make any desired changes, such as staging additional files or removing existing ones.

Editing a Commit in Tower
Editing a Commit in Tower


  1. You can also simply drag one commit onto another to squash them together (hold to fixup commits instead).
Tower – Interactive Rebase with Drag and Drop


And speaking of "fixup," you can also make amendments by typing fixup! followed by the appropriate commit in the commit message area. After that, you can access the branch view to use the "autofixup" feature.

Tower – Autofixup

Git Worktrees for Running AI Agents in Parallel

In the AI coding landscape, it's common to work on multiple features in parallel with your preferred coding agent. If that describes you, then Git worktrees are the way to go! ✌️

A worktree is a separate working directory linked to your main repository. This allows you to have multiple branches checked out simultaneously, each in its own directory.

For example, you can have your main feature branch checked out in one worktree and a hotfix branch in another. You can switch between them seamlessly without needing to stash or commit your changes, making it ideal for running multiple AI coding agents simultaneously.

How Tower Can Help 🔥

In Tower, working with worktrees is a breeze. You can create a new worktree by right-clicking on any branch in the sidebar and selecting "Check out [BRANCH] in New Worktree...".

Creating a New Worktree from a Branch
Creating a New Worktree from a Branch


The "Worktrees" section in the sidebar will help you keep track of all your worktrees.

Worktrees in Tower's Sidebar
Worktrees in Tower's Sidebar

Stacked Branches for Incremental Work

Stacked branches are useful for organizing incremental work with AI agents. For example, instead of creating multiple independent branches for a feature (such as the model and the UI), you can use stacked branches to easily update the dependent branch with any changes.

This approach also makes the final review process easier, aligning with its intended design. This is also known as the Stacked Pull Requests workflow.

How Tower Can Help 🔥

Tower allows you to create stacked branches from any branch by simply right-clicking on a branch and selecting the appropriate option from the context menu.

Tower – Create New Stacked Branch
Tower – Create New Stacked Branch


Since Tower tracks the parent branch, you will be prompted to restack the child branch whenever the parent undergoes changes, ensuring that they remain in sync. You will also be notified if any merge conflicts arise while integrating the new changes.

This even works if you are a Graphite user.

Branch Restacking in Tower

Conclusion

AI is transforming the way we write software. With code generation now possible in seconds, having a clear understanding of your project's history is more important than ever.

By adopting the principles discussed — such as making frequent, atomic commits and utilizing advanced techniques like interactive rebase and Git Worktrees — you can make your version control system the most reliable component of your AI-powered workflow.

We hope you found this guide useful! For more Git tips and tricks, don't forget to sign up for our newsletter below and follow Tower on Twitter / X and LinkedIn! ✌️

Your Download is in Progress…

Giveaways. Cheat Sheets. eBooks. Discounts. And great content from our blog!