恢复大文件的提交并解决二进制合并冲突

Revert commit with Large file and resolve binary merge conflict

我想 push 我提交到 GitHub,但它不允许我,因为文件 Extras.pkl 太大了。我(不小心)添加了文件 7 提交回 dfa4bfe,但目前在我的存储库中无处可寻(它似乎已被删除)。 git revert dfa4bfe 提示

warning: Cannot merge binary files: MuonRate/nHits_distribution.png (HEAD vs. parent of dfa4bfe... Add HRV split graph and z direction dist) 
error: could not revert dfa4bfe... Add HRV split graph and z direction dist

那是因为在同一个提交中有 2 个图像(一个造成了冲突)。

我使用 git checkout --ours/theirs "MuonRate/nHits_distribution.png" 手动分配版本并使用 git addgit commit 提交这些。但后来我得到以下信息:

Your branch is ahead of 'origin/main' by 9 commits.
  (use "git push" to publish your local commits)
You are currently reverting commit dfa4bfe.

Untracked files:
        #some unimportant files

nothing added to commit but untracked files present

注意最后 3 行和最后一行。当我使用 git commit -m "empty commit to escape revert" --allow-empty 时,You are currently reverting commit dfa4bfe. 行消失了。但是如果我 git push origin main,我会得到完全相同的错误,指出文件 Extras.pkl 太大。

问题:如何撤消 Extras.pkl 的提交并解决二进制问题?

Git 日志:

* da43e5a (HEAD -> main) empty commit to escape revert
* e8d3f7a add .gitignore
* 633b6f2 Delete extrapkl
* 9f2366b .
* e2c9712 Add mplstyle
* b3702dc Rerun and delete filters for V9
* dfa4bfe Add HRV split graph and z direction dist
* 76bee13 Plot nHist complete
* 7f227ea First histogram of nHits
* b82b78b Create Multi directory data loop
etc.

注意:,none 我在还原期间的提交出现在历史记录中。 问题在于提交 dfa4bfe Add HRV split graph and z direction dist.

the github page regarding sensitive information 之后,我已经解决了这个问题。供日后参考和其他:

如果问题出在您的本地存储库中,请跳过以下 2 个步骤:

  1. git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY
  2. cd YOUR-REPOSITORY

PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA 更改为您的文件位置,但保留引号。

  1. git filter-branch --force --index-filter \ "git rm --cached --ignore-unmatch PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA" \ --prune-empty --tag-name-filter cat -- --all
  2. 按两次输入
  3. git push ORIGIN MAIN