I hashed together something like this in my dotfiles a few years ago. Big parts were logging each command run to my own history files (marked with machine and date), rotating those logs, and a cronjob to sync it with GitHub.
Only took a few hours to set up.
Do you mean bash/zsh profiles or recent command history?
Command history
script -f filename ?
You could do that with a GitHub action quite easily.