The --abbrev-commit flag can be used in conjunction with git log and git rev-list in order to show partial prefixes instead of the ful
The following shell script, when run in a local repo, prints the length of the longest prefix required to prevent any overlap among all prefix hashes of commit objects of that repository.
MAX_LENGTH=4;
git rev-list --abbrev=4 --abbrev-commit --all | \
( while read -r line; do
if [ ${#line} -gt $MAX_LENGTH ]; then
MAX_LENGTH=${#line};
fi
done && printf %s\\n "$MAX_LENGTH"
)
The last time I edited this answer, the script printed