If you’re using Git as one of your Version Control solutions, you’ve likely run into scenarios that have caused you to split your code across multiple repositories. Let’s look in-depth at 3 common reasons to split Git repos.
- You’re following a component-based development (CBD) methodology because you want to reuse components across projects.
- You’re running into the inherent scalability limitations of Git because you’re building an enterprise grade project.
- You want to separate code based on barriers such as programming language and for organizational reasons, it makes sense to store the code in separate repositories.
No matter what the reason is, splitting up code inside of Git only brings more management overhead. Enterprise grade projects can result in 100s if not 1000s of separate Git repositories. Having to run Git commands within each repository just isn’t a scalable solution.
But there is a better way.
Helix TeamHub is a hosting platform that natively organizes multiple Git repos inside the concept of a “project”. This helps teams understand how components are associated. And with the newly released Helix TeamHub command-line client, hth-cli, you can do even more across Git repos.
Teams can execute Git commands— like clone, checkout, status, commit, and push — across repositories. You can even create, list, and merge code reviews – including multi-repo code reviews – directly from the command line. For big teams working on enterprise grade projects, this saves you time and helps you deliver better code, faster.
Execute Commands Across Repos
The Helix TeamHub command-line client works with Helix TeamHub. We can see here that our project consists of three (3) repos as well as a project wiki.
Our app is supported on multiple devices. We need to add a new version file into each of the Android, iOS, and common code repos. Then we can make the changes available other teammates. To get started, we need to create a manifest repository. This can be done from both the command line and the Helix TeamHub UI. We’ll be using the Helix TeamHub UI. We can give the repo a short name and then in the advanced settings choose to create the manifest repository, as well as generate the default manifest file. We can now see what the manifest repository looks like by viewing the new repository that was automatically created. It is important to note that the manifest repository only needs to be generated once per project, not each time a user wants to use the hth-cli.
Let’s jump to the hth-cli and set up a local working directory using the hth init command. Here we’re leaving out all project details. Notice that the hth-cli will prompt us for the relevant information. After entering the information, we’ll have a new .hth folder.
Now we can pull down all repositories defined in the manifest file in just a single command. Using the hth sync command, we can see the progress from the hth-cli. Use the hth each command to view the contents of each repository. The hth each command acts as a pass thru to the OS in this case.
Now that we have our repositories synched locally, let’s create a new branch called “newfeature” across all of our repos using the hth checkout command. If you only want to create the feature branch on a subset of repos defined in the manifest file, you can use the hth scope command.
Now that we’ve got our new feature branch defined in each repository, let’s add our version file into each repository using the hth each command (hth each ‘echo 2020.1 > VERSION’). We can see this change in each repo by running the hth status command from the project directory. Next, we want to push all of our changes from the working directory to the index using the hth add command. From here, we can commit our changes to the head using the hth commit command. Lastly, we will push our changes to the remote repository using the hth push command. Let’s hop back in the UI to see the changes we’ve made.
If you are using Helix TeamHub Enterprise with Helix Core —Version Control from Perforce — you can do even more. This solution gives you a single source of truth for assets, whether they are being versioned using Helix Core or Git.
Because we have changes that span repositories, and we want to merge all of those changes atomically, we can perform a “multi-repo code review” directly from the command line. Just use the hth mcrcreate command. The client is smart enough to prompt for code review details such as the destination branch, title, and description. It can also detect the source and destination branch, plus the repositories that contain changes.
Jumping back into the UI, we can see that a new multi-repo code review has been created. Designated reviewers can provide feedback on the changes. If everything looks good, you can merge the changes that span repositories in a single, atomic operation.
Of course, we could’ve just stayed in the hth-cli and merged the code review from there as well. If you’re not using Helix TeamHub with Helix Core yet, you can still create standard code reviews for each repository.
Accelerate Git With Perforce
Using Helix TeamHub, with or without Helix Core, helps teams scale and manage all their repos. Using Helix TeamHub command-line client will save your developers time.
Support your teams and simplify their workflows. Try Helix TeamHub free for up to 5 users and start building more with fewer commands.