I have a Go project that uses 2 additional private dependencies. One of them is indirect
MyProj --depends--> MyLib1 --depends--> MyLib2
Problem is when I attempt to go get
it returns error like
$ go get my.repo/my-lib1@latest
go: get my.repo/my-lib2@v1.2.3-0.20230320115558-aa11aa11aa11: invalid version: unknown revision aa11aa11aa11
MyProj has go.mod like
require (
...
my.repo/my-lib1 v1.1.1-0.20230714111111-44ff44ff44ff
)
require (
...
my.repo/my-lib2 v1.2.3-0.20230605111111-33bb22bb33bb // indirect
)
At some point MyLib2 was branched out for a new feature. MyLib1 was pointing on this feature branch. Then MyLib2 feature was merged into master and branch was deleted. MyLib1 was also updated to MyLib2's master branch. Schematically it looks like this:
And now every time when I have to update MyLib1 to latest, the go get
command attempts to fetch deleted branch. Go get
command attempts to fetch MyLib1 and MyLib2 GIT repository, tries to cache all commits and fails on pulling deleted MyLib2's aa11aa11aa11
commit. Workaround is to remove indirect MyLib2 from Project's go.mod
file and run go mod tidy
How to make go get my.repo/my-lib1@latest
to pull only latest revisions of libraries without pulling deleted branches? Is there a way to remove MyLib2's deleted branch aa11aa11aa11
from MyLib1 GIT history so that Go's cache would avoid it?