When managing multiple projects using git, sometimes we tend to forget to push our changes to our SCM(Github, GitLab or other).
Normally you would cd into your repo and perform git status to check whether it is updated. Doing this on all your projects is a bit time consuming and is a repetitive task.
I wrote a very simple script gg(short form of get git) which checks whether all your repos are up to date and pushed to your SCM.
#!/bin/bash
repos=(
$HOME/developer/repo1
$HOME/developer/repo2
$HOME/repo3
$HOME/website/repo4.github.io
$HOME/developer/repo5-lab
)
for i in ${repos[@]};do
if [[ -d "$i" ]];then
if git -C "$i" status | grep -q "nothing to commit, working tree clean";then
echo "✅${i}"
else
echo "❌${i}"
fi
else
echo "invalid repo path"
exit 1
fi
done
exit 0
Three Simple steps to setup
Copy the script into /use/local/bin or /path/to/your/bin and name it as gg(or whatever you want to name it)
Replace the paths in the script with your project repo paths and save it
Make the script executable
And there you go!!
If you type gg(name of the script) in your terminal, you can see all your repo status at a glance.
I hope you found it useful and makes your workflow productive, Thanks for reading till the end.