I made private fork of the public repo on GitHub using this guide https://help.github.com/articles/duplicating-a-repository
git clone --mirror <path-to-some-public-repo>
cd ./some-public-repo.git
git remote rm origin
git remote add upstream <path-to-some-public-repo>
git remote add privatefork <path-to-your-private-fork>
git push --mirror privatefork
I made some work, created my own branch, pushed branch to private fork. Then I fetched updates from upstream to my privatefork
git fetch -p upstream
git push --mirror privatefork
My new branch was deleted during update. Commits still in repo, but branch has been deleted. Of course I could create branch again, but it's a wrong way.
What should I do to update private fork and keep new branches?
I would guess, since you did not publish your new branch to the "upstream" the invoked git fetch -p
:
"[r]emove[s after fetching] any remote-tracking references that no longer exist on the remote."
- git-fetch(1) Manual Page
With other words you may push and change as much as you want (on "privatefork") with every fetch -p
from upstream you're going to remove your changes.
Besides of that: working with --mirror
and --prune
- the whole help-article on GitHub - is mentioned to create 1:1-copies/backups of repositories. If you plan to work with the repository, leave the options away and do "normal" forking.
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.