相关文章推荐
爱运动的奔马  ·  start | Microsoft Learn·  3 月前    · 
健壮的葡萄酒  ·  SpringBoot - ...·  3 月前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Here is the setting:

Background: I want to transfer a large part of my repository to an "archive" repository.

I have two bare repositories: develop_new.git , archive.git

I write into the file "C:\Git\Test\develop_new.git\objects\info\alternates" the following line:

/c/Git/Test/archive.git/objects

Want I want to do:

$ git replace --graft <commit_1> <commit_2>

in order to establish a history link between these two repositories.

commit_1 is the first commit in develop_new.git. commit_2 is the second last commit in archive.git.

Problem:

The following error occurs:

error: object directory /c/Git/Test/archive.git/objects does not exist; check .git/objects/info/alternates.

despite the fact that the directory actually exists.

What could be the problem?

Thanks!

In my tests, I had to use a relative path from the current repo's object store to the alternate object store. That is, given

repo1/ .git/ repo2/ .git/ objects/ info/

in repo2/.git/objects/info/alternates I could say

../../../repo1/.git/objects

but I could not say

/c/repo1/.git/objects

The docs do suggest that absolute paths should work locally, so I considered that maybe it was a path syntax mismatch (because I'm on Windows); and indeed

c:/repo1/.git/objects

works for me.

If you're going to access the repo remotely, absolute paths may again not work (per the docs); in that case you may want to look at using http-alternates

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.