Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top