Reputation: 675
I am trying to use a bare git repo as a bridge between my working repo and the origin
origin ----- bare repo ----- working repo
I can go into the working repo and push and pull from the bare repo. But I also need to go into the bare repo and push and pull form the origin, is that possible?
EDIT
What I've tried so far...
To create the bare repo
mkdir bare_repo
cd bare_repo
git init --bare
git remote add origin path_to_origin
git fetch origin
To create the working repo
git clone path_to_bare
I get a warning: "remote HEAD refers to nonexistant ref, unable to checkout", but it still creates the working repo
git pull origin master
I get an error: "Couldnt find remote ref master"
UPDATE
Turns out I had a write permissions issue, and so I couldn't push from the working repo to the bare repo. So I general I need to check permissions for all my repo locations before asking questions... Now everything is working...
One things is, if someone else pushes a commit to the origin, I will need to fetch that commit from my bare repo and update the branch on my bare repo. The fetch is simple enough
# in bare repo
git fetch origin master
but I dont know the best way to update the branch. I cant pull because there is no working directory. I can get the hash of the new commit using
git ls-remote
and then manually point the branch to it with
git branch -f master <hash>
But it seems like there would be a better way.
But I think that should be a separate question.
Upvotes: 1
Views: 1514
Reputation: 4668
You can clone the original repo as a bare repo with: git clone --bare <repo url>
Upvotes: 2