It may be a very naïve question, but I want to synchronise my local clone of stdlib with the official version. I cannot figure out how to do that with either Github or Github desktop. Do I have to use the Git command-line tools for this or is there an alternative?
I don’t think it’s possible from the GitHub web interface. But not sure.
When working on the translation of Fortran-lang.org, I used these commands:
$ git clone firstname.lastname@example.org:awvwgk/fortran-lang.org.git
$ git remote add upstream email@example.com:awvwgk/fortran-lang.org.git
Now I can import in my own fork the awvwgk’s commits with:
$ git fetch upstream $ git rebase upstream/i18n
And I can see the list of remote repositories with:
$ git remote -v origin https://github.com/vmagnin/fortran-lang.org.git (fetch) origin https://github.com/vmagnin/fortran-lang.org.git (push) upstream firstname.lastname@example.org:awvwgk/fortran-lang.org.git (fetch) upstream email@example.com:awvwgk/fortran-lang.org.git (push)
My fork is
origin. Forked from the
upstream. I guess you can add as many remotes as needed to work with other people…
According to this thread on StackOverflow there is no simple way through the Desktop Client either.
The git command line interface is probably the most straightforward way if you don’t want to install a second GUI client.
Syncing forks and local copies is a bit cumbersome due to the locality of data in git. Especially, if you are dealing with the upstream repo, your own fork and (possible several) local copies.
A strategy that worked nicely for me is relying on the pull bot for syncing my forks on GitHub:
The pull bot will automatically sync your forked repository with the upstream repository, meaning you never have to add the upstream to your local repository (I still do it for other reasons). This only works if you never modify the default branch (formerly known as master branch) of the repository you are working on and always only use feature branches.
There are some neat tricks for the command line like
git fetch --all --prune to clean up the dozens of merged feature branches from a local copy if the remotes are setup correctly.
Regarding Github Desktop:
- From the first tab “Current repository” choose that of stdlib.
- From the second tab “Current branch” choose the one you want to sync, eg “master”
- Now, from the same tab, if you notice, there is a clickable option further down and below all available branches “Choose a branch to merge into master”, click and a window will pop up with available options to merge into master.
For example, in the case of the fortran-lang website, in order to sync my version with the latest, I choose to merge my local master with the upstream/master.
Thanks, everyone. I used @stravos 's receipe and that has worked nicely. I could almost have thought of this myself :).