http://blog.projectrhinestone.org/one-liner-for-changing-all-git-repos-license-times/
pwd=$(pwd);for file in ~/GitHub/*/LICENSE;do cd $(dirname $file);git checkout master;stash=$(git diff LICENSE);if [ -n "$stash" ];then git stash;fi;sed -i "" -e "s/\(Copyright (c) \)[0-9]\{4\}\(-[0-9]\{4\}\)*/\1$(git log $(git log --pretty=format:%H|tail -1) --date=format:%Y --format=%ad)-$(date +%Y)/" LICENSE;git commit -m "Update time for copyright message in license" LICENSE;if [ -n "$stash" ];then git stash pop;fi;git push;done;cd $pwd
自行修改路,便 term 窗口 paste 去就可以了。 POSIX 兼容。 Tested on OS X Yosemite Version 10.10.5 (14F27).
效果:
起始年份 commit log 取第一 commit 的,前年份用的 date 指令,默的格式 GitHub 生成的 Copyright (c) %Y Your Name
。
![]() | 1 49 2016-01-01 15:22:34 +08:00 via Android E 娘干的漂亮,我也去给好友的 gayhub 提几个 PRprprpr hhhhhhhhhhhhhhhhh |
![]() | 2 kn007 2016-01-01 15:25:46 +08:00 漂亮! |
![]() | 3 kumakiti 2016-01-01 15:26:03 +08:00 确实干的漂亮! |
![]() | 5 wbsdty331 2016-01-01 16:30:19 +08:00 不升级 El 吗? |
7 Arthur2e5 2016-01-04 11:39:55 +08:00 用 pushd popd 比 cd 回去优雅啦。另外 quoting 。 |
![]() | 9 KexyBiscuit 2016-01-04 20:26:24 +08:00 via Android @Elethom 不过是活跃用户的 1/2 ,不哭,摸头 |