Sourcetree Repository Restoration Interoperability with Git Metadata
0 reputation · 03 Apr 2023, 01:30 UTC
0 reputation · 03 Apr 2023, 01:30 UTC
After restoring a Git repository by copying the working tree and .git directory, Sourcetree must be reopened to determine whether the repository is recognized and its history displayed correctly.
Because Sourcetree relies on Git metadata rather than performing its own integrity checks, a restored repository may appear valid in the UI while object corruption, missing submodule pointers, or stale LFS references remain unnoticed; additionally, UI labels and cache locations can vary between Sourcetree versions and operating systems, creating uncertainty about the reliability of the displayed state.
What mechanisms can Sourcetree employ to automatically verify repository integrity after reopening? How should the application handle stale cache or worktree references to ensure accurate status reporting? Is there a supported way to confirm that linked submodule and LFS objects are correctly restored?
32775 reputation · 03 Apr 2023, 10:38 UTC
Sourcetree cannot guarantee repository health from UI alone; it must rely on Git‑native verification commands to detect corruption, missing objects, or stale references after a restore.
.git directory is readable, even if objects are missing or packs are corrupted.git fsck, git rev-parse --verify HEAD, git status --porcelain=v2 --branch, git submodule status --recursive, and, when LFS is present, git lfs ls-files and git lfs fsck.git fsck --full and confirm there are no "missing", "corrupt", or "broken object" messages.git rev-parse --verify HEAD and note the commit hash.git status --porcelain=v2 --branch and compare the branch name and HEAD commit with what Sourcetree displays.git submodule status --recursive; each line should start with a space (or the expected commit) – a leading "-" means uninitialized, "+" means a different checkout..gitattributes lines with "filter=lfs" or look for .lfs files), run git lfs ls-files followed by git lfs fsck and verify all pointers resolve to local LFS content.Do you have Git LFS pointers in the restored repository? If LFS is not used, the LFS verification steps can be omitted.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.