this post was submitted on 27 Jul 2023
37 points (100.0% liked)

Git

2910 readers
1 users here now

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Resources

Rules

  1. Follow programming.dev rules
  2. Be excellent to each other, no hostility towards users for any reason
  3. No spam of tools/companies/advertisements. It’s OK to post your own stuff part of the time, but the primary use of the community should not be self-promotion.

Git Logo by Jason Long is licensed under the Creative Commons Attribution 3.0 Unported License.

founded 1 year ago
MODERATORS
 

cross-posted from: https://lemmy.sdf.org/post/1352760

Was digging through a project at work today where some guy in 2014 made 100+ commits in a single day and the only one that had a comment said "upgrading to v4.0".

all 21 comments
sorted by: hot top controversial new old
[–] canpolat 13 points 1 year ago (2 children)

The way I commit on my private branch is different than how I merge those commits to the main branch. When working on the private branch, things can get messy and if they do, I just try to keep certain things separate from each other (refactorings and bug fixes should not go into the same commit). Once the work is done, I do a interactive rebase to tidy things up and then merge them afterwards. Sometimes the changes are not that much and it becomes a squash commit. I would definitely refrain from creating 100 (insignificant and possibly back-and-forth) commits on the main branch.

[–] [email protected] 4 points 1 year ago (2 children)

I wish I had time for that.

[–] canpolat 4 points 1 year ago (1 children)

Maybe my explanation was complicated, but what I describe is not time consuming. It takes at most a few minutes to do all of the things I mentioned. The difficult part is discipline of keeping refactoring separate. Once that's done, the rest is trivial. And not all work include refactoring. That's even easier then.

[–] [email protected] 2 points 1 year ago (1 children)

Discipline is definitely tough. I have tried looking at rebasing tutorials and it always looked pretty tedious to do, hence my comment about time constraints. I should really give it another try though.

[–] canpolat 1 points 1 year ago

Interactive rebase is used to organize (squash, drop, reorder) commits and with some experience is totally painless. Would definitely recommend watching a few videos about it.

[–] Teddly 2 points 1 year ago (1 children)

I used to find rebasing annoying until I started using lazygit. It makes it really easy, now before opening a PR I just interactive rebase on top of latest main and I can easily clean up my commits before opening the PR.

[–] [email protected] 1 points 1 year ago

Sounds interesting, I’ll check it out! Thanks for the link

[–] natecox 13 points 1 year ago (1 children)
[–] jim 5 points 1 year ago

Yep, this is the convention. Unfortunately, I've never been able to enforce it. Encouraging good git commit messages is probably the bottom of the things I can coach. I'd be happy if commits were properly squashed/rebased and that we all followed the same PR merge strategy.

[–] [email protected] 6 points 1 year ago

As someone said in the original post: Conventional Commits. No more discussion is needed. Just do it like the standard and get back faster to the real work.

[–] ssebastianoo 4 points 1 year ago (1 children)
[–] sucks_syntax 3 points 1 year ago (1 children)

We have a monorepo with multiple websites and applications, we also use azure DevOps. Our commit messages are formatted like this: {website/application} - {feature} - {brief description} - {#work item} so e.g. "Auth - MFA - auto focus login field #162589"

The most beneficial part is the work item number, being able to link the code changes directly to the business logic is huge.

Also beneficial for bug fixes, push the commit with the bug id and the code changes are linked on the ticket automatically.

[–] tuna_casserole 1 points 1 year ago

Oh I like the work item number idea. We've been putting in a line to explain why the change is being made. Being able to link directly to a card or something is noice.

[–] malloc 1 points 1 year ago

I follow this format:

brief description

- change1
- change2

<reference to issue, if applicable>

I add the issue number since most decent issue trackers with integrated VCS (ie, github, bitbucket + jira) will automatically hyperlink it to the actual issue

[–] [email protected] 1 points 1 year ago

Most of mine tend to follow this format:

filename: brief description

More in-depth description and rationale if needed

It's not often where I will modify multiple files within a single commit, but if I do, I will typically use a section or subsystem name rather than a single filename.

[–] [email protected] 1 points 1 year ago* (last edited 1 year ago)

Driven through me as Lead Developer, we've adopted a Conventional Commits style using convco for conformance check and changelog/release note generating (customized template).

feat(auth): Introduce configurable permissions (ticketref) (!MR)

We've extended allowed/used types of fix and feat to include docs, test, refac, and misc. We explicitly decided against types like @CodeSupreme linked like style, perf, build, ci, chore, revert. Slim number of types has value. build, ci are scoped to misc(proj) or misc(ci). Reverts are of the original type or misc chores with impact - not a disconnected separate type - and indicated in the commit title.

We develop in branches, and are free to be messy until we found and implemented a solution at which point we clean up commits to an intentional, documented changeset (using Git interactive rebase with squashing etc).

We use a semi-linear history, so once a changeset is approved we rebase and merge with a merge commit - so we only have at most one merged parallel branch in the history tree. The generated changelog only considers merge commits - where the changeset is documented as a whole (same title and description as the merge/review request).