Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

git - How do I update my bare repo?

I created a bare repo to publish my repository, but I can't figure out how to update the bare repo with the current state of the main repository.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you want to duplicate all the objects from the main repo, do this inside the main repo:

git push --all <url-of-bare-repo>

Alternatively, do a fetch inside the bare repo:

git fetch <url-of-main-repo>

You cannot do a pull, because a pull wants to merge with HEAD, which a bare repo does not have.

You can add these as remotes to save yourself some typing in the future:

git remote add <whatever-name> <url-of-other-repo>

Then you can simply do

git push --all <whatever-name>

or

git fetch <whatever-name>

depending on what repo you're in. If <whatever-name> is origin, you can even leave it out altogether.

Disclaimer: I'm not a git guru. If I said something wrong, I'd like to be enlightened!

Update: Read the comments!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...