4 ms·
You can do this today in standard git with https://www.davidchudzicki.com/posts/first-parent https://www.davidchudzicki.com/posts/first-parent Summary: every f
by jefftk 5y ago
You can do this today in standard git with https://www.davidchudzicki.com/posts/first-parent https://www.davidchudzicki.com/posts/first-parent
Summary: every feature is merged with 'main' as the first parent. Then, whenever interacting with history, you tell git you only want it to consider --first-parent
- kevin_b_er 5y agoThe author makes the argument that 'first parent' being the original branch is a mere convention. And he's right. If someone does the merge while checked out on the feature branch, then commits it _as_ the master branch, then the first-parent concept breaks.
- thrashh 5y agoBut that problem is easy to fix with 0 disadvantages: Don’t do that. Don’t do it for the same reason that you have a convention of useful commit messages.
- ianlevesque 5y agoI masquerade as proficient in this field and I'm pretty sure I've done that just by accident with git a few times. Assuming any developer on your team is much better than monkeys on typewriters when it comes to git will lead to disappointment.
- exclipy 5y agoMake a precommit hook that enforces this. Done.
- Groxx 5y agoThis only enforces it where you have the hook installed. And it cannot be pre-installed on people who have newly cloned the repo. Which makes it nearly useless. Not totally - the people who know about it benefit - but it's extremely far from safe. The only way to really enforce this is to add this kind of thing to your "main" remote repo that everyone pushes to.
- xmodem 5y agoI've probably done it a bunch of times on my side projects too, but in any environment where code review is enforce you should probably be enforcing using the tooling to do the merge too, and not giving individual developers permission to push to the main branch.
- TomSwirly 5y ago"Don't do that" is not a good solution to errors which are hard to spot and easy to make!
- joshka 5y agoThe other part is - merging is software development, write a commit message better than "Merge branch 'foo' into main" e.g. Add new feature foo to main menu ...
- Ericson2314 5y agoYeah just need to make git bisect --first-parent, and then the solution be obvious.
- jefftk 5y agogit bisect already supports --first-parent: https://git-scm.com/docs/git-bisect https://git-scm.com/docs/git-bisect
- Ericson2314 5y agoOh great! That's new since last I tried.
- exclipy 5y agoThis. There is no need to introduce a new concept like "commit groups" to permeate through everything. Just use merges and display them nicely. The problem is getting all the visualization tools on the same page. Bazaar got this right. Their official UI displays a linear history with the ability to expand any merge commit to show the side branch. https://commons.wikimedia.org/wiki/File:Bazaar_Explorer_-_Log.png https://commons.wikimedia.org/wiki/File:Bazaar_Explorer_-_Lo...
- vertere 5y agoThanks, I did not know that about Bazaar. I wish that were the norm in Git-land. But I can see why people might still desire more explicit constructs to handle history organization. The expectation that the commit graph should be both logical and historical causes a sort of cognitive dissonance, which these sorts of conventions don't fully resolve.
- nixpulvis 5y agoIn your .gitconfig l = log --graph --abbrev-commit --date=relative Im not sure about collapsing history though.
- TomSwirly 5y agoMerges are truly horrible, though. They're a commit with two parents, one of which has no real meaning anymore because it doesn't exist anywhere else. They break a lot of tools because of this.
- ric2b 5y ago> one of which has no real meaning anymore because it doesn't exist anywhere else. What do you mean? That's the feature branch, what's the issue?
- joshka 5y agoThe first parent is (generally) main. The second parent is the last commit of a series of commits starting at a commit, sometime in the past on the main branch, followed by all the new commits that represent the feature that is being merged. Merges are horrible, if you don't have a mental model of git that aligns exactly to the above.
- dfabulich 5y agoWe need Github and other Git commit visualization tools to offer a "first parent" option!