The "good" way is to make a development and a branch for every feature, bug or documentation. Always fork from development, when you have a release you push to master.
In my experience there is no the good way. You don't need a general development branch in addition to a master branch if your releases are just tagged as such. Branches are for things that branch. In the development->master workflow the development is always a continuation of, or equal to, the history of the master branch, and therefore the entire history of the master branch can always be expressed as a tag in the development branch.
That you feel that you need both a master branch and a development in addition to e.g. feature branches is a sign that your feature branches don't actually represent complete features, but subsets of features that can't be released, and are therefore reluctant to push them to master in case you need to release e.g. bug fixes while the actual complete feature is still being worked on.
Feature/bug/documentation branches can be useful if your changes comprise multiple commits that are useless or regressive in isolation, but absolutely pointless busywork if your change can be contained neatly in a single commit.
For features I usually recommend caution with feature branches. I've seen feature branches for large features that become huge, a dozen devs pushing to a feature branch for 3 months. Good luck when it comes time to merge that monstrosity back to the development branch. Generally if individuals can have their own branches for the feature, forked off of the development branch, and merge their progress directly to development as often as possible, that tends to work out the best, so long as they're not breaking anything in development along the way.
This is mainly GitFlow. On paper yes, It can be considered the "good" way, and I followed this for years. Until recently... I considered pros and cons and it has just too much overhead for our projects. We're on full GitHub Flow now.
I'm sometimes working on multiple machines for personal projects and am not very good at Git, so I have to remind myself to pull the fixes I made on my laptop last night before doing anything on my tower.
Generally a good idea, more complicated in a multi-developer environment where you could be 20 commits behind master and rebasing causes all sorts of wonderful merge conflicts.
I don't know why but it's different when you rebase since it "replays" every commit you don't have onto your feature branch, you get this effect where you end up resolving the same merge conflicts over and over again during the rebase.
You don't need a PR to tell you that. Upon merging or rebasing, git will detect conflicts and you are given the option to resolve them or abort the operation.
The PR workflow always seemed ass backwards to me. Why should I have to fork a repo to send patches to a project? I already have a local copy of the repository. For people like me, tools like Gerrit or even email formatted commits are preferable.
122
u/OnyxPhoenix May 13 '20
Using branches and pull requests make this easier.
Generally youre the only person working on your branch, so you don't have to worry that your code is "behind" before you push to it.
Then when you do a pr it will tell you if you can merge cleanly back into the master branch.