开发者

How to grab the last 12 months from cygwin "date" and use the months for git sync

I'm trying to compare the trees of a repo as they were at the end of the month for the past 12 months, to see what changed. I am a newb - so far my code basically looks like this:

for month in Jan Feb Mar Apr May Jun Jul Aug Sep

git checkout $(git rev-list --before "$month 1 2011" -n 1 HEAD)

I'd like to make this work for the last 12 months, going back to the previous year. I want it to by dynamic - how do I make a loop that iterates over the last 12 months, ending on the current month? I want the month value to be a var开发者_开发知识库iable I can use both in for "..." and in my git checkout ... line.

Thanks!


You might want to try something like this:

for i in {1..12}; do
    git checkout $(git rev-list --before "$(date -d "$(date -d +%Y-%m-15) -$i months" +%Y-%m)-01" -n 1 HEAD)
    ...
done
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜