如何将文件推送到过去的时间? [英] How to push a file to past time?
问题描述
我在我的路径中有这个脚本,叫做 git-rcd
,它改变了你想要的任何提交(不只是最后一个提交) GIT_COMMITTER_DATE 和 GIT_AUTHOR_DATE
p>
#!/ bin / bash
#commit
#date YYYY-mm-dd HH:MM:SS
$ b $ commit =$ 1datecal =$ 2
temp_branch =temp-rebasing-branch
current_branch =$(git rev-parse --abbrev-ref HEAD )
date_timestamp = $(date -d$ datecal+%s)
date_r = $(date -R -d$ datecal)
echodatecal = $ datecal => date_timestamp = $ date_timestamp date_r = $ date_r
if [ [-z$ commit]];然后
出口0
fi
git checkout -b$ temp_branch$ commit
GIT_COMMITTER_DATE =$ date_timestampGIT_AUTHOR_DATE =$ date_timestampgit commit --amend --no-edit --date$ date_r
git checkout$ current_branch
git rebase --autostash --committer-date-is-author-date$ commit - - $ temp_branch
git branch -d$ temp_branch
我是采取了我刚刚做的最后一次提交并键入:
git rcd @'1天前'
code>
和presto!我最后一次提交已经在昨天完成。
它改变了你想要的任何提交:
git rcd @〜2'1 day ago'
这只会改变 HEAD〜2
(而不是 HEAD〜
或 HEAD
)
该脚本即使在Windows上也能正常工作。
完成更改后,按(或 git push --force
如果你以前推错了日期)。并且你的连胜情况得到保留。
Yesterday, I made changes on a project file but forgot to commit and push it on github. I don't want that my contribution streak breaks after 51 days..so I would like to push that commit to yesterday so that my streak keeps on... Is that possible?
Thank you very much in advance!
I have that script in my path, called git-rcd
, which changes GIT_COMMITTER_DATE
and GIT_AUTHOR_DATE
of any commit you want (not just the last one)
#!/bin/bash
# commit
# date YYYY-mm-dd HH:MM:SS
commit="$1" datecal="$2"
temp_branch="temp-rebasing-branch"
current_branch="$(git rev-parse --abbrev-ref HEAD)"
date_timestamp=$(date -d "$datecal" +%s)
date_r=$(date -R -d "$datecal")
echo "datecal=$datecal => date_timestamp=$date_timestamp date_r=$date_r"
if [[ -z "$commit" ]]; then
exit 0
fi
git checkout -b "$temp_branch" "$commit"
GIT_COMMITTER_DATE="$date_timestamp" GIT_AUTHOR_DATE="$date_timestamp" git commit --amend --no-edit --date "$date_r"
git checkout "$current_branch"
git rebase --autostash --committer-date-is-author-date "$commit" --onto "$temp_branch"
git branch -d "$temp_branch"
What that allows me is take the last commit I just did and type:
git rcd @ '1 day ago'
And presto! My last commit has now been done yesterday.
It changes any commit you want:
git rcd @~2 '1 day ago'
That would only change the HEAD~2
(and not the HEAD~
or HEAD
)
The script works even on Windows.
Once the change is done, push (or git push --force
if you pushed before with the wrong date). And your streak is preserved.
这篇关于如何将文件推送到过去的时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!