object directory does not exist - Git operations fail after upgrade or STASH_HOME update
症状
After upgrading Stash to version 3.2+ (from a version prior to 3.2) or having moved STASH_HOME
to a different location, git operations (e.g. git push
) fail:
git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags origin branchname:branchname
POST git-receive-pack (700 bytes)
remote: error: object directory C:/StashData/data/repositories/26/objects does not exist; check .git/objects/info/alternates. [K
remote: fatal: unresolved deltas left after unpacking [K
error: unpack failed: unpack-objects abnormal exit
Pushing to https://username@stash.server/scm/projectkey/reponame.git
To https://username@stash.server/scm/projectkey/reponame.git
! [remote rejected] branchname -> branchname (unpacker error)
error: failed to push some refs to 'https://username@stash.server/scm/projectkey/reponame.git'
Completed with errors, see above."
You could could also be getting the following screen upon browsing forks:
'/usr/bin/git cat-file -t refs/heads/master:' exited with code 128 saying: error: object directory /abdera/user0/atlass/application-data/stash/data/repositories/292/objects does not exist; check .git/objects/info/alternates.
原因
For an unknown reason the forked repository (e.g. ID 26) of the upstream repository (e.g. ID 45) still refers to the old path in the alternates
file which Stash uses to implement the fork functionality. Either the Stash 3.2 upgrade (which included a data directory migration) partially failed or the script that runs on application start up that detects changes to the location of STASH_HOME
(and updates all alternates
files accordingly) has failed.
ソリューション
- Stop Stash.
- Correct the path in the
alternates
file leaving therepoID
unchanged:STASH_HOME/shared/data/repositories/<repoID>/objects/info/alternates
(versions 3.2+)STASH_HOME/data/repositories/<repoID>/objects/info/alternates
(versions prior to 3.2)
- Start Stash.