I am still learning git but I have run into a situation that confuses me so if anyone can straighten it out for me I would appreciate it.
On github I have created a Dolibarr fork that I work on, since I do not have (or want) write permission on the main repo. I cloned the fork to my laptop and do the work on there, sync the fork on github, pull and then push back to my fork. This works.
However, is it possible to not having to use the github web to sync the fork? That is, is there some way to use the git console commands to do this?
My remotes:
$ git remote -v
origin git@github.com:bos4711/dolibarr-bos.git (fetch)
origin git@github.com:bos4711/dolibarr-bos.git (push)
upstream git@github.com:Dolibarr/Dolibarr.git (fetch)
upstream git@github.com:Dolibarr/Dolibarr.git (push)
What I am asking for is: is it possible to sync “origin” from “upstream” directly in the console? If yes, how do you do that?
(I have read “Pro Git” and checked Stack Overflow but cannot find out how to that)
Hey!
Yes absolutely, you can sync your fork with upstream directly from the command line without using the GitHub web interface. Your remote setup looks perfect for this.
Here’s the typical workflow I use:
git checkout develop
git fetch upstream
git merge upstream/develop
git push origin develop
This fetches the latest changes from the upstream Dolibarr repository, merges them into your local develop branch, and then pushes the updated branch to your fork on GitHub.
If you want to be extra safe and avoid potential merge conflicts, you can use rebase instead:
git checkout develop
git fetch upstream
git rebase upstream/develop
git push origin develop
The key thing is that you already have your upstream remote configured correctly pointing to the main Dolibarr repository, so you’re all set. Just make sure you’re on the right branch (usually develop for Dolibarr) before doing the fetch and merge.
You can also create a simple alias or script to automate this if you find yourself doing it frequently. This approach gives you much more control than the GitHub web sync and is actually faster once you get used to it.
Clément Houde - Founder of Dolicraft
Without using the Gibhub web, how can I sync the Github-fork with the Dolibarr-repo?