使用 git filter-repo 并合并后重复提交

问题描述 投票:0回答:1

我在项目存储库中的某些提交重复时遇到一些问题。不幸的是,我一定犯了导致这种重复的错误发生在四个月前,所以我对我所做的事情的记忆相当模糊。

该项目可以在这里找到:https://github.com/benvessely/brevets。这一切都是因为我意识到我不小心在我的存储库中跟踪了一个机密文件,credentials.ini 一段时间,并且该文件随后被推送到了 Github。我想从我的提交历史记录中删除这个文件,所以我使用了 git filter-repo,我认为它工作正常。我记得在这里做了一些涉及拉动和变基的事情,尽管我又记不清了。抱歉,我无法提供更多帮助。

此推/拉发生在提交之后,哈希值以 a72b0 开头。然后我又进行了几次提交,然后在最近的提交中进行了某种合并。不幸的是,我真的不记得为什么要进行这次合并,并且

git show
没有告诉我任何事情。此后,我停止了该项目的工作 4 个月,显然没有注意到我的存储库中存在重复。

我现在所处的位置是,在哈希值 4aa07 和 a3dee 的提交之间(不包括在内),我相信有两个分支具有重复的提交,一个包含 credential.ini 文件,另一个不包含。提交确实具有不同的哈希值,但它们包含相同的消息和相同的文件,唯一的区别是credentials.ini。对于 4aa07 之前(复制之前)和 a3dee 之后(复制之后)的所有提交,这些提交也都没有 credential.ini 文件。只是中间的部分是重复的,并且仍然包含错误文件。

需要注意的一件事是,当我使用 git log –graph 时,它显示了图表的一些奇怪的偏差,这确实让我认为合并可能是问题的一部分。我对所有这些概念的掌握仍然不完全扎实,但看起来有问题的分支来自远程,然后合并到我的本地分支中。

基本上,我想知道如何摆脱那些包含机密文件的重复提交?我知道,由于我无法提供详细信息,这可能是一个棘手的问题,但如果有人愿意看一下这个问题并让我知道他们的想法,我将非常感激。预先感谢!

git git-merge git-filter-repo
1个回答
0
投票

你的存储库看起来像这样。

> git log --graph --decorate --oneline
*   74d2daf (HEAD -> master, origin/master, origin/HEAD) Merge branch 'master' of https://github.com/benvessely/proj6-rest-vessely
|\
| * a72b0d4 Submit now doesn't work if there are any notes (i.e. errors). Bug still exists with submitting without refocusing first
| * 7b4c763 Error messages go away after  change of km/miles (though  may return immediately)
| * a50d818 Submit button delays before submit to give time for AJAX; other little adjustments
| * dbd4f79 Return button now works as desired with starting options too
| * b76e770 Fix return key behavior in table; move JS from calc.html into calc.js
| * 15b7c2e Added to and revised README, though could still be reworked more
| * 5b2f24e Fixed bug for consumer program when database empty
| * 6d31a0d brevets_proj6 is now brevets
* | 2399188 Adjust time delay for submit
* | de2a148 Errors resizing table fixed by changing table spacing and error width
* | a3deeb2 Restoring state of files before performed filter-repo to remove credentials.ini from history
* | 368362d Submit now doesn't work if there are any notes (i.e. errors). Bug still exists with submitting without refocusing first
* | 688371b Error messages go away after  change of km/miles (though  may return immediately)
* | 981e001 Submit button delays before submit to give time for AJAX; other little adjustments
* | f8bf5a9 Return button now works as desired with starting options too
* | 5c3b741 Fix return key behavior in table; move JS from calc.html into calc.js
* | fad18bf Added to and revised README, though could still be reworked more
* | a18a83c Fixed bug for consumer program when database empty
* | 9227a27 brevets_proj6 is now brevets
|/
* 4aa0739 Delete data-samples and DockerRestAPI, renamed brevets_proj6 to brevets
* 45d26df Basic consumer program working
...

我猜测 a72b0d4 是您过滤之前的历史记录,2399188 是您要保留的新历史记录。我进一步猜测,在过滤之后,你尝试

git push
并且 Git 说你的分支已经“分歧”,你应该
git pull
来解决这个问题。
git pull
git fetch
+
git merge
,这就是合并的方式。

分支只是指向提交的标签。我们可以通过使用

git reset --hard
将 master 移动到合并之前的 2399188 来消除重复项。然后,我们可以使用令人困惑的名称“强制推送与租赁”安全地移动遥控器上的主机。 > git reset --hard 2399188 > git log --graph --decorate --oneline * 2399188 (HEAD -> master) Adjust time delay for submit * de2a148 Errors resizing table fixed by changing table spacing and error width * a3deeb2 Restoring state of files before performed filter-repo to remove credentials.ini from history * 368362d Submit now doesn't work if there are any notes (i.e. errors). Bug still exists with submitting without refocusing first * 688371b Error messages go away after change of km/miles (though may return immediately) * 981e001 Submit button delays before submit to give time for AJAX; other little adjustments * f8bf5a9 Return button now works as desired with starting options too * 5c3b741 Fix return key behavior in table; move JS from calc.html into calc.js * fad18bf Added to and revised README, though could still be reworked more * a18a83c Fixed bug for consumer program when database empty * 9227a27 brevets_proj6 is now brevets * 4aa0739 Delete data-samples and DockerRestAPI, renamed brevets_proj6 to brevets * 45d26df Basic consumer program working ... > git push --force-with-lease

	
© www.soinside.com 2019 - 2024. All rights reserved.