593 private links
Thanks to git log -1
it is trivial to view the latest commit in a repo, and combined with find ... -exec ...
we can easily do that for multiple repos at once (for example see my commits
bash function).
Turns out doing the same for the earliest commit in each repo is not at all trivial. Here is my approach (it should be said up-front that it's not pretty). But I wanted to get a handle on when I started working on some repos, and this pulled out the data I needed without having to do it manually for each individual repo.
taha@asks2:/media/bay/taha/projects/ansible/pub/roles
$ find . -maxdepth 2 -name ".git" -exec sh -c "git -C {} --no-pager log --all --pretty=format:\"%cs %h%d %s [%cn]\" | tail -n1" \; -exec printf " %s\n" {} \; | sort -n
2021-03-14 02506d4 Initial commit [taha] ./texlive/.git
2021-03-14 14ddd9a Initial commit [taha] ./desktop-tools/.git
2021-03-14 2bfe5bc Initial commit [taha] ./R/.git
2021-03-15 0c2deda Initial commit [taha] ./calibre-web/.git
2021-04-02 7a2bdb2 Initial commit [taha] ./iriun-webcam/.git
2021-04-13 167ef2d First commit [taha@asks2] ./shaarli/.git
2021-05-28 ca70e06 Initial commit [taha] ./wallabag/.git
2021-06-09 3d4891e Initial commit [taha] ./lxd-server/.git
The directory roles
contains a bunch of git repos (and possibly also a few folders that are not repos, which we exclude from find with -name ".git"
. Then for each repo, we list all commits (across all branches) using a custom format but then, importantly, only showing the last one which is the earliest commit.
To be able to tail this git command (and not the entire find command) we need to put it inside sh -c ...
.
Then we use a second exec statement to append the current directory name (so we can orient ourselves in the output) and then sort the entirety on the output (which thanks to our custom git format lists the commit date in the first column). Note that piping strips the colour from the git output, so no need to set colours in our pretty-format
.
- https://stackoverflow.com/questions/51376361/getting-commit-history-from-multiple-repositories-for-some-period
- https://stackoverflow.com/questions/5188914/how-to-show-the-first-commit-by-git-log (this approach with
git rev-list --max-parents
did not work in my case, not sure why) - https://andrewrea.co.uk/posts/git-log-over-multiple-repos
- https://stackoverflow.com/questions/50882822/view-logs-of-multiple-git-repositories
- https://stackoverflow.com/questions/6712423/how-do-i-count-the-number-of-commits-made-in-to-all-repos-hosted-by-gitosis-on-m
- https://stackoverflow.com/questions/49388069/what-does-git-log-1-do
- https://stackoverflow.com/questions/307015/how-do-i-include-a-pipe-in-my-linux-find-exec-command
- https://stackoverflow.com/questions/1371261/get-current-directory-or-folder-name-without-the-full-path
You do not need to master every aspect of git to make use of it in your daily work.
Even a little bit of git will take you a long way towards best practice with regards to reproducibility!
Enjoy these videos
- https://youtu.be/s3JldKoA0zw (science setting, also awesome soundtrack!)
- https://www.youtube.com/watch?v=CvbLVVRzJF8 (business setting)
Git introductions or tutorials
- The missing semester of your CS education, online classes on the command-line, Git, the shell and more from MIT
- Git Magic, by Ben Lynn
- Become a Git pro in just one blog. A thorough guide to Git architecture and command line interface, by Uday Hiwarale
- How To Make Life Easier When Using Git, by Shane Hudson
- Confusing git terminology, Julia Evans, 2023-11-01
- How Git Works!, Julia Evans, 2024-06-03
- Inside .git, Julia Evans, 2024
- Git en välskriven guide på svenska från IT-institutionen vid Uppsala universitet
Opinions or comments
- How to be a 'good' git evangelist?, by Sunniva Indrehus, 2021-09-02
- Git is my buddy: Effective Git as a solo developer, Mikkel Paulson, 2021. Via https://www.eamoncaddigan.net/posts/git-links
- Nobody cares about your Git history, Dan Kelch, 2024
- https://matklad.github.io/2023/12/31/git-things.html
I would like to have a PDF viewer that lets me click a button (or press a key) to move backwards in the PDF file's git history. In effect, git checkout <commit> file.pdf
but automatically moving back in the commit history on each keypress.
Combined with something like the overview mode of pdfpc, that could make for a very efficient way to glance through the history of a PDF file, such as a thesis or a beamer presentation.
So far I have not found any PDF viewer software with something akin to that.
Maybe I should just open the PDF in VSCodium and use the built-in git support? Would that provide something similar?
Gitea is great. So is Codeberg. The ability to share repos, issues, and users across Gitea instances, would be awesome.
Git itself is already federated and decentralised, but there is still a need for federation of the remote repo and its facilities.
The idea of some sort of federation between Gitea instances has been around since 2016.
- https://forgefriends.org/blog/2021/11/22/what-is-forgefriends/
- https://social.gitea.io/@gitea/1075767916260526973
- https://forum.forgefriends.org/t/nlnet-grant-application-for-federation-in-gitea-deadline-october-1st-2021/354
- https://forum.forgefriends.org/t/forge-federation-webinar-january-19th-2022-10am-noon-utc-1/538#a-10000-feet-view-of-problems-with-forge-silos-and-their-solutions-4
- Software Forge performance index (maintained by SourceHut)