How to pull a number of Git repositories

I normally work with many repos on the identical time and customarily group them inside an identical listing, named after the corporate.

Let’s take an instance, if I am working for “GreatEmployer LLC.” I will have a listing most likely named greatemployerinc and one listing for every repo I work inside. One thing like:

tree view

As a substitute of navigating every certainly one of them with cd after which manually run git pull department, I got here out with the next command that I run from greatemployerinc -the repos containing listing.

find

It should discover any subdirectory within the present one (greatemployerinc), without going deeper than the primary stage (delimited by mindepth 1 and maxdepth 1) and execute a git pull within the corresponding git dir (if it’s a repo).

Remember, it would run a git pull on the present department that every repository is definitely stepping on. Additionally, take into account the pull might fail when you have pending adjustments (will probably be proven on the console output, anyway) and also you might must deal with these circumstances manually, or contemplating including an --autostash choice to the offered command.

Conclusion

So, we created a fast small command to run a pull in a number of repos without delay, then we created an alias for it so it’s easier to run later.

Avatar

About Shachindra Yadav

I, Shachindra Yadav, a Cloud Certified, DevOps and technology enthusiastic person, more passionate to learn and write blogs in my free time.

View all posts by Shachindra Yadav →