Forgotten work in git repos

I'm often switching from one git repo to another, and it's sometimes hard to keep up on local clones “up-to-dateness”. To sync everything from remotes, I already made myself a script I referenced here. However I had nothing to check the status of the local work I have sometime locally which may not be commited or not pushed.

To get an overview of that, so I made myself a script to parse all git repos from my home folder, and “probe” their status to check for leftover work I may have forgot about.

To sumarize the interesting bits, here are the two lines which do more of the core work of the script:

STATUS_REPORT="$(git -C "${REPO}" status --short)"
COMMIT_REPORT="$(git -C "${REPO}" log --branches --not --remotes --oneline)"
  • The first uses status --short which report the list of files which are either new, updated, modified, deleted, ect.. This part helps to check if I have some non commited work.
  • The second line log --branches --not --remotes --oneline prints the logs related to commit message which are not on remote branches. This part cover about non pushed commits.

With some parallel “magic”, and triggering Lazygit when needed, my script fullfill its goal !

Julien Pericat
Linux Sysadmin, SysOps & DevOps friendly

Happily automating and putting things in containers.