git-merge with repository on local filesystem
Asked Answered
O

2

14

For some context: I just upgraded Ubuntu which broke my existing gitosis installation (see here: bug #368895), and have just reinstalled gitosis from packages. I now want to migrate my whole config and set of repositories from the old gitosis installation (which still exists and can be pulled from but is otherwise broken).

I now have two gitosis-admin directories locally, one for each gitosis installation. One has a full history, the other's is empty. I want to pull across this history. Here's what's happening though:

me@server:~/gitosis-admin-new$ git merge ../gitosis-admin-old/
fatal: '../gitosis-admin-old/' does not point to a commit

... where there is are git repositories in ~/gitosis-admin-old/ and ~/gitosis-admin-new/

I'm probably going to need to do this for the other repositories too, which have much longer and more important histories, so copying and committing as one is not an option.

What am I doing wrong? I've tried pointing to .git/HEAD which as I understand is a commit, but that doesn't work. Could someone explain how to do this? Thanks!

Occultism answered 30/10, 2009 at 19:59 Comment(0)
A
26

You need to use git pull with repository, not git merge (which is for branches):

git pull ../gitosis-admin-old/

You might need to select a branch in remote to merge, e.g.:

git pull ../gitosis-admin-old/ master

If you need to do this merge only once, then using git remote add like in jamessan answer is unnecessary work. On the other hand if you would be revisiting the remote (pulling more than one time), this solution would be better than using git pull <location> <branch>.

Almaraz answered 30/10, 2009 at 23:25 Comment(2)
Accepted; gets one up on jamessan's answer because of the 'master'! Thanks very much :)Occultism
In the new version of git you have to use also ` --allow-unrelated-histories`Alamo
B
5

You need to create a remote for that repository and then fetch & merge (or simply pull) from there.

git remote add admin-old file://$HOME/gitosis-admin-old
git pull admin-old
Babylon answered 30/10, 2009 at 20:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.