简体   繁体   中英

push from bare git repository

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.

您可以使用以下命令将原始存储库克隆为裸存储库: git clone --bare <repo url>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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