I think I generally understand the benefit of using branches in a development workflow. My question is when it comes to reverting small changes, are branches easier or safer to revert in some way than regular commits? For example, if you apply a patch which adds one line of code, is it better to do that in a branch and merge it, or is a pushed commit sufficient?
Asked
Active
Viewed 27 times
0
-
It's hard to tell what you're asking here. Are there benefits to branching? Yes. It all depends on your workflow. If you are having someone QA your work, it might be easier on a branch, but in a CI/CD world, there would be no need for that. Can you clarify your question by adding details to your use case or describe what isn't working for you? – jmargolisvt Jun 01 '19 at 18:21
-
I acknowledged in the first sentence understanding the benefit of branching in development. The question was if branches were preferred or necessary in small changes particularly when it comes to **reverting** those changes. With the example I provided of adding one line of code for a patch, I meant is it "overkill" to use a branch to add one line of code and then merge? AND is that branch with one line of code **once it has been merged** any different than a commit with that same line of code? I hope this helps. Sorry for any confusion. I am new to all of this. – Tone Loc Jun 01 '19 at 18:40
1 Answers
0
It really does depend. Most of the time, it's probably overkill to make branch for a one-line change because those changes are unlikely to be as risky as larger changes. But if that one line changes everything about a function or which function gets run, etc. you might want to have that on a branch so you can really test it before you pull it into master.
Is that any different after it's been merged? Well, you'll get a merge commit (unless you rebase instead), but rolling back is effectively the same process. You might want to read more about how a merge commit differs from a regular commit and about using git revert
.

jmargolisvt
- 5,722
- 4
- 29
- 46