How to manage multiple Git repositories with a simple bash function

In the past I have already worked with a project that consisted of multiple Git repositories in a common project folder. For tracking each repository’s individual state together, Google’s repo tool was used. I ended up using mostly its powerful repo forall subcommand to execute various bash or git commands over the whole or subset of those projects.

Now, I was faced with the same situation, but without repo already in place. Could I get some of that forall feeling back, but without installing that (relatively) giant tool? It turns out, 9 lines of bash give me most of what I missed:

Continue reading “How to manage multiple Git repositories with a simple bash function”

How to store HTTPS credentials for Git in WSL

If you are stuck on Windows for any reason but got most of your fun Linux tool with you, good chances are you are using Windows Subsystem for Linux (WSL). With it comes a full Linux distribution (I use Ubuntu, but there are plenty of options: Alpine, Debian, Fedore, Kali, openSUSE) backed by their whole package ecosystem behind them. Historically, you could only run command line tools, but even GUI support for running graphical applications is now (since April 2021) available as a preview feature.

Ok, back to this post’s topic: say you are using Git within WSL to work on some code project. But unfortunately, for some reason, that project’s main development server only supports HTTPS authentication. Typically, this would cause you to have to interactively authenticate by Username + Password on every git fetch or git push operation. Not so much fun.

If you are on Linux, you have some options available (with the good recommendation: if SSH is possible, use it!), but under WSL, you can use a simpler trick.

Continue reading “How to store HTTPS credentials for Git in WSL”

How to git push to multiple remotes with one command

There are multiple questions with even more answers on this exact question at Stack Overflow. The simplest answer, which I failed to find again, looks like this. Add the following lines to your repo’s .git/config:

	pushall = !git push origin master && git push github master && git push remote3 master

Simply change remote and branch names to fit yours and from thereon, a git pushall will do all the work.