1

我有一个heroku应用程序。我克隆了它并开始研究它。有一些问题,我不小心在本地删除了 .git 目录并使用 .git 初始化了一个新目录git init

在那之后,我做了几次提交,并在我的代码中添加了几个特性。现在我想将代码推送到heroku dyno。

所以我做 git remote add origin git-remote-url。尝试git push但出错,执行 agit pull会出现以下错误 -

warning: packfile .git/objects/pack/pack-887ccc7bf1196e49089e449ae1edd93c87c785b8.pack cannot be accessed
fatal: bad object 00eb66f14b52f3808720aaa35285a4f32e019a05
error: heroku.com:******.git did not send all necessary objects

我该怎么办?

4

1 回答 1

0

也许这与您当前回购的状态(您git init又一次)有关,其中不包含已发布的完整历史记录。
您需要再次克隆您的 heroku reop,以便应用您在本地(但不完整)repo 中所做的新提交;

就像是:

git clone --bare yourHerokuRepo
cd /path/to/myapp                                       # where you deleted the `.git`)
git remote add localHeroku /path/to/yourHerokuRepo.git
git branch -m master oldmaster                          # where your new commits are
git fetch localHeroku                                   # get the full history
git checkout -b master localHeroku/master               # now working on the branch with
                                                        # a full history
git cherry-pick ..oldmaster                             # re-apply all your commits
git push
于 2013-05-06T11:01:55.910 回答