Option to preserve git history on repo creation from template #11974

Open
opened 2025-11-02 09:53:20 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @silverwind on GitHub (Nov 8, 2023).

Feature Description

When a repo is generated from a template repo, Gitea squashes all existing commits from the template repo into the new repo. This squashing is undesirable for cases where the intention is to merge future changes from the template later into the generated Repo because such merges fail without a shared git history:

$ git merge upstream
fatal: refusing to merge unrelated histories

It works with the --allow-unrelated-histories but ideally I would like to see a option "Git History" added here, or a separate Checkbox in the form "Preserve Git History".

image
Originally created by @silverwind on GitHub (Nov 8, 2023). ### Feature Description When a repo is generated from a template repo, Gitea squashes all existing commits from the template repo into the new repo. This squashing is undesirable for cases where the intention is to merge future changes from the template later into the generated Repo because such merges fail without a shared git history: ``` $ git merge upstream fatal: refusing to merge unrelated histories ``` It works with the `--allow-unrelated-histories` but ideally I would like to see a option "Git History" added here, or a separate Checkbox in the form "Preserve Git History". <img width="501" alt="image" src="https://github.com/go-gitea/gitea/assets/115237/714209ec-3d85-433d-ad95-051e222940ca">
GiteaMirror added the type/proposal label 2025-11-02 09:53:20 -06:00
Author
Owner

@traverseda commented on GitHub (Nov 9, 2023):

How would that work with variable expansion? The templated gitea instance can't just be merged in, since any templated variable would have a different value.

@traverseda commented on GitHub (Nov 9, 2023): How would that work with variable expansion? The templated gitea instance can't just be merged in, since any templated variable would have a different value.
Author
Owner

@silverwind commented on GitHub (Nov 9, 2023):

I'd say first perform a full clone of the template repo, then do the variable replacement in a commit on top of that, so the new repo ends up with num-commits + 1. Do not modify variables in old commits. If there are no replacements, do not create the commit at all.

I assume that's already happening under the hood, but hidden by that squash.

@silverwind commented on GitHub (Nov 9, 2023): I'd say first perform a full clone of the template repo, then do the variable replacement in a commit on top of that, so the new repo ends up with num-commits + 1. Do not modify variables in old commits. If there are no replacements, do not create the commit at all. I assume that's already happening under the hood, but hidden by that squash.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11974