Automating my workflow [2]

Sebastiaan Nijland
Kaartje2go
Published in
2 min readMay 31, 2018

In a previous post I shared a shell script for automating git fetching multiple repositories. I recently noticed that I often forget to checkout the base branch for repositories in which I do a lot of work. So, I created a new script to reset all repositories to their "base" branch:

Not all repositories use the same default branch. This stackoverflow answer provided me with a nice one-liner to get that default branch name. Note that if your default branch is not correct locally (maybe you changed it server-side), this will not work. You could use the second part of the gist above to handle that case.

Reset to the default branch for multiple repositories with a single script

Feel free to copy either of these functions — do remember to replace Workspace with the name of the directory containing your own repositories, and maybe replace the names in both DIRS arrays with your own repositories.

Do you have scripts like this yourself? Leave a comment!

--

--