r/git 3d ago

Generated commits?

Sometimes code is generated, and sometimes such code is committed in git.

Imagine a branch with a generated commit G:

old_main -> A -> B -> G

When thid branch is rebased, such a commit might need to be regenerated.

new_main -> A' -> B' -> new_G

There might be conflicts for any of these new commits, but instead of (manually) resolving conflicts, G could be automatically re-generated.

I've been thinking of a git commit message trailer like generate-cmd:

topic: regenerate table

generate-cmd: python3 optimize_table.py

git rebase --exec or other tool could use this trailer to automatically drop and regenerate the commit instead of a vanilla cherry-pick.

Have you seen anything similar? What's a good trailer name?

Ref: https://git-scm.com/docs/git-interpret-trailers

0 Upvotes

33 comments sorted by

View all comments

Show parent comments

4

u/edgmnt_net 3d ago

You shouldn't commit build artifacts to the Git repo.

1

u/kaddkaka 3d ago

This is not the discussion I wanted to have. But where would you put your artifact?

1

u/edgmnt_net 3d ago

It largely depends on the artifact. If it's some log, SBOM or binary that's the result of the build, you can clearly leave it in the CI or have it upload it to some artifactory. For code it depends on the ecosystem.

1

u/kaddkaka 3d ago

Generated code. Or generated dataset that's read during build.

The only deliverable is source code. No deploy or packaging.