GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: make `submodule.update()` after `submodule.deinit()` work by Byron · Pull Request #2175 · gitpython-developers/GitPython

Conversation

@Byron

@Byron Byron commented Jul 16, 2026

Copy link
Copy Markdown
Member

Git's submodule deinit command removes the submodule checkout but retains its repository under the parent repository's .git/modules directory.

Submodule.update() previously treated the missing checkout as a completely uninitialized submodule and attempted to clone it again. The clone could not reuse the existing module repository, preventing a deinitialized submodule from being initialized again through GitPython.

Detect a valid retained repository before entering the clone path. Restore the checkout's .git file and the module repository's worktree configuration, reset the retained repository to recreate its index and working tree, and restore the submodule URL in the parent configuration. Continue using the existing clone behavior when no valid retained repository is available.

Tasks

  • refackiew

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Copilot AI review requested due to automatic review settings July 16, 2026 05:23
Copilot started reviewing on behalf of Byron July 16, 2026 05:24
View session
Copilot AI reviewed Jul 16, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Submodule.update() so that a submodule can be re-initialized via GitPython after it was deinitialized with git submodule deinit, by reusing the retained repository under the parent repo’s .git/modules/ rather than attempting a fresh clone.

Changes:

  • Detect and reuse an existing retained submodule repository under .git/modules/ when the worktree checkout is missing.
  • Recreate the submodule checkout by restoring the .git file + module core.worktree config and resetting to repopulate index/worktree.
  • Add test coverage to validate update-after-deinit behavior (including init=False, dry_run=True, and nested submodule names).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
git/objects/submodule/base.py Adds a “reconnect retained repo” path in Submodule.update() to restore a deinitialized checkout without recloning.
test/test_submodule.py Adds tests covering submodule.update() behavior after submodule.deinit() across several modes and a nested submodule case.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread git/objects/submodule/base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Copilot AI review requested due to automatic review settings July 16, 2026 05:35
@Byron
Byron force-pushed the submodule-deinit-fix branch from 72895f4 to eb7bf7b Compare July 16, 2026 05:35
Copilot started reviewing on behalf of Byron July 16, 2026 05:37
View session
Copilot AI reviewed Jul 16, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread git/objects/submodule/base.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@codex @Byron
fix: make submodule.update() after submodule.deinit() work
b9d82c0
Git's `submodule deinit` command removes the submodule checkout but retains
its repository under the parent repository's `.git/modules` directory.

Submodule.update() previously treated the missing checkout as a completely
uninitialized submodule and attempted to clone it again. The clone could not
reuse the existing module repository, preventing a deinitialized submodule
from being initialized again through GitPython.

Detect a valid retained repository before entering the clone path. Restore
the checkout's `.git` file and the module repository's worktree
configuration, reset the retained repository to recreate its index and
working tree, and restore the submodule URL in the parent configuration.
Continue using the existing clone behavior when no valid retained repository
is available.

Co-authored-by: Sebastian Thiel <[email protected]>
Copilot AI review requested due to automatic review settings July 16, 2026 05:46
@Byron
Byron force-pushed the submodule-deinit-fix branch from eb7bf7b to b9d82c0 Compare July 16, 2026 05:46
Copilot started reviewing on behalf of Byron July 16, 2026 05:47
View session
Copilot AI reviewed Jul 16, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Byron
Byron merged commit 15527ef into main Jul 16, 2026
53 of 54 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@Byron
Byron deleted the submodule-deinit-fix branch October 5, 2026 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@Byron @codex
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.