问题标签 [git-fsck]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
42 浏览

git - 仅使用 git fsck 恢复 LaTeX 文件

我不小心使用 git stash 而不是 git stash -u 删除了大量 LaTeX 文件。我按照此处的说明使用以下命令恢复了其中的一些:

问题是这包括一堆垃圾日志文件,我想修改这个命令,以便我只恢复其中包含“\begin{document}”字样的文件。通过修改上面代码中的 grep 步骤,这似乎应该很容易实现,但我对复制的代码的理解不够好,无法自己做到这一点。

0 投票
1 回答
35 浏览

git - How do I use git-filter-repo to fix a bad date

I have a git repo that was converted from RCS via CVS many years ago. When I tried to push it to GitHub it was rejected because the initial two commits had bad dates:

When I look at these commits, it is clear that the dates are bad (they are negative):

This seems like something git-filter-repo should be able to handle. I saw flags for fixing emails and names and commit messages but nothing for dates. I tried a run where I just pruned unreachable commits, and it left the bad dates in place. Then I tried to use git fast-export and edited the negative numbers with the correct unix time stamps. When I used git fast-import into an empty repository, I got plenty of stats but the empty repository stayed empty, probably because the commit structure was disrupted. I'm guessing the only way to fix this is to use the commit callback of git-filter-repo, but I'm not sure how to fix the dates.

I tried

and it ran fine, but it had no effect on the bad dates. I tried doing the same thing but double-quoted the dates (in case they were read as strings), again to no avail.

I saw an existing question on the same topic, but the answers don't say how to use git-filter-repo to fix dates: How can I fix "bad date" issues in a git repository?