简体   繁体   English

git-svn - #object#在/ opt / local / libexec / git-core / git-svn第4706行的存储库中不存在

[英]git-svn - #object# doesn't exist in the repository at /opt/local/libexec/git-core/git-svn line 4706

on

git svn dcommit

it starts commiting and then I get this 它开始提交然后我得到了这个

A   spec/controllers/authenticated_system_spec.rb
A   spec/controllers/sessions_controller_spec.rb
A   spec/controllers/users_controller_spec.rb
A   spec/fixtures/users.yml
A   spec/helpers/users_helper_spec.rb
A   spec/models/user_spec.rb
A   vendor/plugins/haml/init.rb
A   vendor/plugins/restful_authentication
7235d9150e8beb80a819923a4c871ef4069c6759 doesn't exist in the repository at /opt/local/libexec/git-core/git-svn line 4706
Failed to read object 7235d9150e8beb80a819923a4c871ef4069c6759 at /opt/local/libexec/git-core/git-svn line 570

any ideas how one goes about fixing this one? 任何想法如何解决这个问题?

tried inspecting with git fsck --full but git repo and all git commands seem to work fine just can't dcommit. 尝试用git fsck --full检查 - git fsck --full但git repo和所有git命令似乎工作正常,不能dcommit。

Did you create submodules in your Git repo ? 你在Git仓库中创建了子模块吗?
This blog post seems to mention that as an issue. 这篇博文似乎提到了这个问题。

As of Jan 2009 git-svn does NOT work with submodules. 截至2009年1月, git-svn不适用于子模块。
There is no good way to map submodules to svn and the perl script that implements git-svn just bombs when doing git svn dcommit . 在执行git svn dcommit时,没有很好的方法将子模块映射到svn和实现git-svn的perl脚本只是炸弹。

You need to go back and rewrite history. 你需要回去重写历史。
You should be able to use git commit --amend . 你应该能够使用git commit --amend

$ git tag bad mywork~5
$ git checkout bad
$ # make changes here and update the index
$ git commit --amend
$ git rebase --onto HEAD bad mywork

I had this same problem (where I had done a git clone and I'm using git svn). 我有同样的问题(我做了一个git克隆,我正在使用git svn)。 Here's the command I used to remove the submodule: 这是我用来删除子模块的命令:

git filter-branch --index-filter \
'git rm --cached --ignore-unmatch path/to/the/formerly/misbehaving/module'

I found this wonderful solution on this blog 我在这个博客上发现了这个很棒的解决方

This method does essentially the same as the accepted answer from @VonC but is expanded to make it easier to follow. 此方法与@VonC中接受的答案基本相同,但会进行扩展,以便更容易理解。

The situation 情况

This is the error I was getting when issuing git svn dcommit 这是我在发出git svn dcommit时遇到的错误

#object# doesn't exist in the repository at /usr/lib/git-core/git-svn line 5305
Failed to read object #object# at /usr/lib/git-core/git-svn line 922

I had a number of commits in git that I was attempting to push upstream, and #object# was the SHA1 hash id of one of those commits 2d061be916dc4c2d54eed7b169f1dd80ecf04bc4 in my case. 我在git中提交了一些我试图向上游推送的提交,而#object#是我的情况下其中一个提交2d061be916dc4c2d54eed7b169f1dd80ecf04bc4的SHA1哈希id。

I had included several other git repos from another sources into my project tree. 我从其他来源中包含了几个其他git repos到我的项目树中。 While I hadn't explicitly added them as git submodules I did git add <existing_repo_path> . 虽然我没有明确地将它们添加为git子模块,但我确实git add <existing_repo_path> git notices the .git file and adds existing_repo_path as a special case directory (ie as a submodule). git注意到.git文件并将existing_repo_path添加为特殊情况目录(即作为子模块)。 These directories are the herring bones that cause git-svn to choke. 这些目录是导致git-svn窒息的鲱鱼骨头。

To Fix 修理

find . -name .git

This will find any directory that was added as a submodule. 这将找到作为子模块添加的任何目录。

./.git   # Expect this one
./path/to/submodule1/.git
./path/to/other/submodule/.git

Remove the special directories from git while leaving the files on the filesystem: 从git中删除特殊目录,同时将文件留在文件系统上:

git rm --cached ./path/to/submodule1 
git rm --cached ./path/to/other/submodule

Rename or delete the .git files from the submodule directories. 从子模块目录重命名或删除.git文件。 Renaming the .git files offers a little bit of protection since you could revert back. 重命名.git文件提供了一些保护,因为您可以恢复。

mv path/to/submodule1/.git path/to/submodule1/dot.git
mv path/to/other/submodule/.git path/to/other/submodule/dot.git

If you had explicitly added submodules you may need to remove the .gitmodules file at the root of the repo. 如果您已明确添加子模块,则可能需要删除repo根目录下的.gitmodules文件。 You should probably edit this file first to check if there is anything in it you want before removing it. 您可能应该先编辑此文件,以便在删除之前检查其中是否有任何内容。

git rm .gitmodules

The submodule directories can now be added back into git and will be treated as ordinary subtrees (ie no longer submodules or special case directories). 现在可以将子模块目录添加回git,并将其视为普通子树(即不再是子模块或特殊情况目录)。

git add ./path/to/submodule1  ./path/to/other/submodule

Commit these new files. 提交这些新文件。

git commit -a -m "Changed submodules to ordinary directories"

The head of the git repo is now good. git repo的负责人现在很好。 But git-svn will still choke because it will attempt to create versions from the git history. 但git-svn仍然会窒息,因为它会尝试从git历史中创建版本。 This means the git history needs to be changed. 这意味着需要更改git历史记录。 My approach is to squash all of the git commits made since the last successful git svn dcommit into a single commit. 我的方法是将自上次成功的git svn dcommit以来所做的所有git提交git svn dcommit到单个提交中。 That way the new single commit will contain only the current head and not the troublesome 'submodule' versions. 这样,新的单个提交将仅包含当前头部而不包含麻烦的“子模块”版本。

To find the last successful svn commit use: 要查找上次成功的svn提交,请使用:

git svn log -n 1 --show-commit

I get something like: 我有类似的东西:

r2917 | 094ed52 | rue | 2015-12-04 15:39:58 +0000 (Fri, 04 Dec 2015) | 2 lines
<commit message>

The output shows the SVN number ( r2917 ) followed by the equivalent git commit id ( 094ed52 ) 输出显示SVN编号( r2917 ),后跟等效的git commit id( 094ed52

Next start an interactive rebase of all the versions since this commit: 接下来启动自此提交以来所有版本的交互式rebase:

 git rebase -i 094ed52

This will open an editor with something like this: 这将打开一个编辑器,如下所示:

pick 16b5fcc Changed submodules to ordinary directories
pick c964dea Some changes
pick 06cf8ee Added some things
pick 094ed52 Some other changes

pick means keep this commit, squash means include these changes into the next commit. pick意味着保持这个提交, squash意味着将这些更改包含在下一个提交中。 Replace all 'pick' with 'squash' except the first line. 除第一行外,将所有'pick'替换为'squash'。

pick 16b5fcc Changed submodules to ordinary directories
squash c964dea Some changes
squash 06cf8ee Added some things
squash 094ed52 Some other changes

Save and exit this file and you should get a new single commit. 保存并退出此文件,您应该获得一个新的单一提交。

git svn dcommit

Now works! 现在有效!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM