Multiple git local repositories for switching context efficiently

Ngo Minh Tri
2 min readFeb 25, 2022

--

Photo by Pawel Olek on dribbble.com

Hi folks, the idea could be applied to any software project you are working on. However, the article is written from an iOS engineer’s point of view; the definitions and examples will be shown in iOS programming.

🤪 Problem

While implementing a feature ticket, have you ever got disturbed by another priority issue? Did you use git stash to save the current changes and switch to another git branch?

Unfortunately, the branch that you switch just now needs to run pod install or carthage update to resolve dependencies, and the more libraries you use, the longer it takes.

💡Solution

To solve it, I use multiple local repositories:

Step 1: I create two different local repositories by cloning from a single origin:

Step 2: Setup the terminal with two different colors. Using zsh, right-click on the tab, and I can change the tab color. If you noticed, I put the empty tab in between to avoid tab selection mistakes. Yay, we’re all human!

Step 3: Mark Finder folder with two different color to prevent confusing yourself. Right-click on the folder, then select the colors matching the zsh terminal tab colors above.

🎉 Conclusion

By doing three simple steps above, switching context is easier than ever:

  • It saves time on update dependencies.
  • It saves time on cleaning/building/re-indexing Xcode workspace. Now, we have multiple independent workspaces.
  • It reduces git stash command.

On the other hand, we should consider wisely:

  • The laptop storage capability.
  • Confident in git command for pull/push via origin.

Thank you for reading. Please clap if you found it helpful 👏

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Ngo Minh Tri
Ngo Minh Tri

Written by Ngo Minh Tri

Wherever you go, go with all your heart.

Responses (1)

Write a response