gitbranchshallow-clone

git: delete grafted branch


I am facing an issue with git. I have a shallow copy of remote repo. In my copy there was two branches cloned. There were grafted i.e. truncated by depth, so while one branch is based on another, in my shallow clone they are independent. One day they have been merged into one branch (look at graph). So second branch (e1a4728..249aeec) no longer needed in my shallow copy. I made git to not to fetch that branch, and to not to fetch tags on it, but i still can't get rid of commits (especially objects) from that branch.

Note: i tried gc and prune but had no success :(

* 38455ea 2021-03-04 | Raise minimum CMake version to 3.16 (HEAD -> master, origin/master) [Nicolas Fella]
* df9117d 2021-08-09 | specify KAboutData::productName() [Michail Vourlakos]
*   949e9c5 2021-08-09 | Merge branch 'v0.10' into master [Michail Vourlakos]
|\  
| * e1a4728 2021-08-08 | crash:dont show settings dialog in early startup [Michail Vourlakos]
| * b7188ab 2021-08-06 | update to v0.10.0 [Michail Vourlakos]
| * a1da0ba 2021-07-27 | disable inattention blocked slide-in when no needed [Michail Vourlakos]
| * 1cf1aeb 2021-07-26 | respect indicators iconOffsetX/Y values properly [Michail Vourlakos]
| * edc254d 2021-07-25 | always show/hide applets popups properly [Michail Vourlakos]
| * 170f14c 2021-07-24 | restack applets internal ClickEffect [Michail Vourlakos]
| * 249aeec 2021-07-21 | SVN_SILENT made messages (.desktop file) - always resolve ours (grafted) [l10n daemon script]
* f7032f7 2021-08-08 | crash:dont show settings dialog in early startup [Michail Vourlakos]
* 2f6808b 2021-08-01 | Define new KPackageStructure property in kpackage structures [Alexander Lohnau]
* c02e4b6 2021-08-01 | Consistently name kpackage structures [Alexander Lohnau]
* 71f9e89 2021-07-27 | disable inattention blocked slide-in when no needed [Michail Vourlakos]
* 47702a5 2021-07-26 | respect indicators iconOffsetX/Y values properly [Michail Vourlakos]
* f2c401b 2021-07-25 | always show/hide applets popups properly [Michail Vourlakos]
* d84e50a 2021-07-24 | restack applets internal ClickEffect [Michail Vourlakos]
* 27c6225 2021-07-24 | SVN_SILENT made messages (.desktop file) - always resolve ours [l10n daemon script]
* d600bbe 2021-07-21 | SVN_SILENT made messages (.desktop file) - always resolve ours [l10n daemon script]
* 834f71d 2021-07-17 | major:update LastActiveWindow implementation [Michail Vourlakos]
* 72ff760 2021-07-17 | fix "favorite" icon name typo [Michail Vourlakos]
* e0e3f19 2021-07-16 | pref option to disable geometries broadcasting [Michail Vourlakos]
* 19defa0 2021-07-11 | drop WinTracker::availableScreenGeometry calcs (grafted) [Michail Vourlakos]


Solution

  • I managed it! The catch was that fetch --depth=10 --update-shallow download commits from both sides of merge commit. So you need either manually edit .git/shallow for second branch to eliminate these commits or specify such depth, that merge commit will be the last in your history or will not be present at all.