简体   繁体   中英

Mirror git repo into new branch

I want to mirror one of my repos into a privat one to make some non public changes but still getting updates from the public one. The problem with normal mirror is that all the time i update the privat repo my changes get deletet. Is there a way to fix this?

My idea was to make it like this:

Repo A is public and Repo B is privat. My privat repo has the branches main, repoA, my fixes. Now i want to mirror repo A into repo B branch repoA.

But this also destroyed branch my fixes all the time i tried updating.

You don't want to use --mirror . Using that option is why you are having trouble. The --mirror option forces exactly the behavior you are seeing and don't want. It causes your changes to be blasted when you update from the original repo. You only use --mirror when you want the copy to never differ at all from the original (once updated).

In your case, you want to use --bare instead, as it will provide the part of the behavior of --mirror that you do want, that of creating just a copy of the underlying repository without a working directory. But unlike --mirror , --bare does not cause future changes to the copy to be lost when the copy is updated from the original. If you understand what a straight "clone" does with no behavior changing flags, then you know what --bare does. The --bare flag only affects the form that the repo takes on disk. It doesn't change anything about how updates are applied between repos.

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