Most Git workflows say to never commit to your fork's master because then your master branch will diverge from origin. However, wouldn't it work to just rebase your commits (from your master branch) on the upstream's master? I know it's a little more complicated, but I don't see why this is bad practice.
Not committing to master prevents colliding commits and having to merge each time 2 people change the same file.
Yes it is a bad practice, Ideally there should not be any direct commit in master branch.
Your first commit to master should be an empty repository. Your next commit to master should be a merge commit from the develop branch or a temporary release branch, and it should be stable, tested, and ready for deployment (if it's an application) or public distribution (if it's a library).
If you are on a feature branch, you can checkout to the master branch and then merge your feature branch - git checkout master and then git merge <feature branch> , and then push your changes again using git push origin master .
Most people would probably not want to rebase every time they want to pull from upstream because you lose some history metadata (timestamps, potential squashing, etc). But for other people this may not be an issue.
Another reason would be for pull-requests. Ideally, you would have the content of your pull-request on a topic branch which then (hopefully) get's merged into your upstream, after which you simply delete that topic branch and pull from master. This way you don't have your old (now duplicated) commits still in your history.
There is something to be said in the ability to be able to keep your master branch "pure" in the sense that anytime you want to can pull your master and have no conflicts. This way 6 months after you fork you can still at a single glance see what is "theirs" and what is "yours".
It is technically possible, but confusing for the maintainer of the original repo.
git fetch upstream
(not by your own fork as well)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With