我想从我的git仓库中删除两个已经不存在的文件。
我将它们放进去,提交了,试图推送,但它们太大了。所以我把它们拿出来,继续工作,然后提交,尝试推送,但它仍然给我同样的错误。我想它们还在历史记录中。
我认为我让问题变得更糟了,因为我在那个分支上继续工作,并做了1次提交。然后我将该分支合并回主分支。
所以我搜索了解决方案,找到了bfg。
但页面上的说明对我来说没有意义。
首先,
我应该从哪里克隆?我的github.com上的远程仓库没有我添加大文件后所做的提交和合并。但是指示似乎让我从那里获取它。(我从本地仓库克隆了)。
接下来,
这对我很有意义。是的,我目前已经检出了
我将它们放进去,提交了,试图推送,但它们太大了。所以我把它们拿出来,继续工作,然后提交,尝试推送,但它仍然给我同样的错误。我想它们还在历史记录中。
我认为我让问题变得更糟了,因为我在那个分支上继续工作,并做了1次提交。然后我将该分支合并回主分支。
所以我搜索了解决方案,找到了bfg。
但页面上的说明对我来说没有意义。
首先,
$ git clone --mirror git://example.com/some-big-repo.git
我应该从哪里克隆?我的github.com上的远程仓库没有我添加大文件后所做的提交和合并。但是指示似乎让我从那里获取它。(我从本地仓库克隆了)。
接下来,
$ java -jar bfg.jar --strip-blobs-bigger-than 100M some-big-repo.git
“some-big-repo.git”是镜像仓库还是普通本地仓库?(我使用了镜像仓库。)
然后我检查了我的历史记录已经更新并尝试了:
$ cd some-big-repo.git
$ git reflog expire --expire=now --all && git gc --prune=now --aggressive
我在镜像克隆中遇到了一个错误。
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To /home/cole/main_repo
+ 94b9a0d...c7c4317 work -> work (forced update)
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '/home/cole/main_repo'
这对我很有意义。是的,我目前已经检出了
master
。但是,我应该做什么其他的呢?如果我尝试其他方法,我只能看到问题的发生。
git push https://github.com/<远程>
。然后它就不会尝试推送到本地 repo 并给我那些错误。但是当我从 repo 拉取一个新的克隆时,有些东西丢失了。我只需从我的本地 repo 添加它们并提交和推送即可。现在我很清爽。希望这就是它应该工作的方式。 - user4084811