Created
June 17, 2018 04:54
-
-
Save zjuchenyuan/1711b2ba98940c4346f41ffd7f0ee350 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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() | |
os.chdir("githubrepo") | |
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"] | |
subprocess.run(cmd) | |
os.system("git push") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment