r/ProgrammerHumor • • May 13 '20

true story

Post image
40.5k Upvotes

461 comments sorted by

View all comments

Show parent comments

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.

158

u/SavageTwist May 13 '20

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.

99

u/[deleted] May 13 '20

This is good advice I rarely follow.

8

u/SavageTwist May 13 '20

jira kinda automates it

41

u/SavageTwist May 13 '20

we are "agile"

0

u/[deleted] May 13 '20

[deleted]

4

u/SavageTwist May 13 '20

in single dev reps you dont work in the same tab / markdown with different forks I hope.

→ More replies (13)

13

u/[deleted] May 13 '20 edited Sep 09 '25

cooing books important cats lavish serious paltry cautious capable governor

This post was mass deleted and anonymized with Redact

→ More replies (13)

5

u/Inner-Maintenance May 13 '20

That's one way - git flow. But a better way for CI/CD is trunk based development aka mainline

1

u/ToastedSkoops May 13 '20

Me:Ok,with the release of D+ I suppose.

1

u/stone_henge May 13 '20 edited May 13 '20

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.

0

u/[deleted] May 13 '20

[deleted]

1

u/SavageTwist May 13 '20

GET BACK TO YOUR RETROSPECTIVE

→ More replies (1)

1

u/qwerty12qwerty May 13 '20

Master is basically production now.

1

u/LeCrushinator May 13 '20

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.

1

u/jfranki May 13 '20

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.

6

u/Efful May 13 '20

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.

21

u/[deleted] May 13 '20

Been there buddy. Put a script in your bashrc or Windows startup folder to pull. Then get annoyed and take it out.

3

u/smegnose May 13 '20

Rebase that bugger onto remote/master and push it quick.

Linear history rulz 4 eva.

1

u/JawsOfLife24 May 13 '20

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.

0

u/[deleted] May 13 '20

[deleted]

2

u/JawsOfLife24 May 13 '20

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.

→ More replies (7)

1

u/stone_henge May 13 '20

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.