Git makes it super easy to keep your own fork up-to-date with it’s upstream source.
DO NOT keep downloading files you think have changed and copying them over manually, this is both cumbersome, unnecessary, and error-prone.
Option 1: GitHub (Fork to a public Repo)
NB: Unfortunately there’s no way to fork to a private repo in GitHub. This meas you should either use banana’s build-args from the dashboard for your API keys, or choose a different method below.
- Fork the repo
(Uncheck “Copy the
main branch only” if you want access to other branches too).
- To keep it up-to-date, go to YOUR FORK’s page on github:
You can compare the changes (if you want) or simply click Update branch, and with just that one click, you get:
You can now
git pull locally to pull in the merged changes from (your) github repo.
Option 2: Command line
# Do this once to add the upstream repo as a "remote"
$ git remote add upstream firstname.lastname@example.org:kiri-art/docker-diffusers-api.git
# Fetch upstream's latest updates (of all branches)
$ git fetch upstream
# Merge the updated code into your fork
$ git merge upstream/main # or upstream/dev, etc.
Option 3: Bare Clone / Mirror Push
See this post below, with big thanks to @Klaudioz.
Please ask below if anything is not clear, or if you have suggestions to improve this for others.
There is another option. Keep a private fork for a public repository if you want to add new “secret” functionality or some credentials.
Do a bare clone of the public repo.
Create a new private one.
Do a mirror push to the new private one.
Create a new empty private repository via Github.
Clone the public repository that we want to base our private repository on:
git clone --bare https://github.com/foo/public-repository.git
Move into the cloned repository and execute a push with the
git push --mirror https://github.com/foo/private-repository.git
--mirror flag push ensures that all the branches and tags that are available in the public repository are replicated in the new location.
The public repository that we cloned in step 2 can now be deleted:
rm -rf public-repository
In order to work on the private repository, we just need to clone it:
$ git clone https://github.com/foo/private-repository.git
$ cd private-repository
Oh, great, thanks! Never worked that way before, thanks for sharing and for the detailed step-by-step! Adding a link to this post as Option 3, and will add a note for Option 1 that it can’t be used to make a private repo (thanks for the reminder).