我试图使用git过滤器更改本地提交的时间戳,但我只是得到了这个错误,并且没有对提交进行任何更改。有没有办法改变commit的时间戳而不是这样,或者修复命令之后出现的错误?
ia@a:~/Desktop/testGit$ git filter-branch --env-filter \
'if [ $GIT_COMMIT = b1d63c62a3a1139a18cf0349980db9f2df331ff2]
then
export GIT_AUTHOR_DATE= "Sun Mar 4 12:12:19 2018 +0200"
export GIT_COMMITTER_DATE="Sat May 19 01:01:01 2007 -0700"错误:
fi' Rewrite b1d63c62a3a1139a18cf0349980db9f2df331ff2 (1/2) (0 seconds passed, remaining 0 predicted)
/usr/lib/git-core/git-filter-branch: 1: [: missing ] Rewrite
f4c6559bcc18b496f8b258a0a7d142d8bee323b8 (2/2) (0 seconds passed,
remaining 0 predicted) /usr/lib/git-core/git-filter-branch: 1: [:
missing ]
WARNING: Ref 'refs/heads/master' is unchanged发布于 2018-03-05 12:18:06
要只编辑一次提交,请使用interactive rebase。跑
git rebase --interactive b1d63c62a3a1139a18cf0349980db9f2df331ff2~(注意波浪号!)在打开的编辑器中,验证第一个提交是否为b1d63c6,并在第一列中编辑其命令-将pick替换为edit。保存todo文件并退出编辑器。git rebase在第一次提交时停止。
编辑提交:
GIT_AUTHOR_DATE="Sun Mar 4 12:12:19 2018 +0200" GIT_COMMITTER_DATE="Sat May 19 01:01:01 2007 -0700" git commit --amend --no-edit继续重新设置基准:
git rebase --continue等待git完成并验证结果:
git show --format=fuller $NEW_SHA1_FOR_REBASED_COMMIT(由于rebase更改了提交ID,因此需要新闻sha1 ID)。
https://stackoverflow.com/questions/49102984
复制相似问题