Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
say you have a private repo, which is not suitable for push to github
but you want github to show your activity for this repo
so, this script will help you sync commit message to `githubrepo`, using empty commits
used commands:
git log --all '--pretty=format:%ad|%s'
git commit -m "message" --date "Sun Jun 17 12:48:07 2018 +0800" --allow-empty
import subprocess
import os
gitlog = subprocess.check_output("git log --all --pretty=format:%ad|%s".split()).decode()
targetgl = subprocess.check_output("git log --all --pretty=format:%ad".split()).decode().split("\n")
for line in gitlog.split("\n")[::-1]:
line = line.split("|")
t = line[0]
message = line[1]
if t not in targetgl:
print(t, message)
cmd = ["git","commit", "-m", message, "--date", t, "--allow-empty"]
os.system("git push")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.