A from-scratch, byte-compatible clone of Git's core plumbing commands, built in Java as a learning project.
Building each command exactly like real Git (same object format, same .git-style layout) to understand version control internals deeply — not just approximate the behavior.
Add an alias so you can run gitbean <command> like a real installed tool, instead of retyping the full classpath every time.
Check your shell first:
echo $SHELLEdit ~/.bashrc (or ~/.zshrc if using zsh) and add:
alias gitbean='java -cp ~/code/gitbean/target/classes com.kuwarte.gitbean.App'Reload it:
source ~/.bashrcNow gitbean init, gitbean add test.txt, etc. work from any directory.
Whenever you change the Java source, you still need to recompile first:
cd ~/code/gitbean && mvn compile
mvn compile exec:java -Dexec.mainClass="com.kuwarte.gitbean.App" -Dexec.args="<command> <args>"Note: always chain
compilebeforeexec:java— Maven won't auto-recompile otherwise, and you'll silently run stale code.
Never run gitbean commands directly inside the gitbean/ project folder — it creates a .gitbean/ folder and test files that clutter your actual source repo.
Instead, use a separate sandbox folder as a sibling to gitbean/:
~/code/
├── gitbean/ <- this repo (source code only)
└── sandbox/ <- test playground, separate git repo (or no repo at all)
mkdir -p ~/code/sandbox
cd ~/code/sandbox
echo "hello world" > test.txt
echo "second file" > test2.txt
gitbean init
gitbean hash-object -w test.txt
gitbean cat-file -p <hash>
gitbean add test.txt
cat .gitbean/indexReset the sandbox to a clean slate anytime:
cd ~/code/sandbox
rm -rf .gitbean test.txt test2.txt| Command | Description |
|---|---|
init |
Creates .gitbean/ repo structure |
hash-object [-w] <file> |
Hashes a file as a blob; -w also stores it |
cat-file -p <hash> |
Prints an object's content |
cat-file -t <hash> |
Prints an object's type |
cat-file -s <hash> |
Prints an object's size |
add <file> |
Hashes + stores a file as a blob, stages it in the index |
gitbean init
gitbean hash-object -w test.txt
gitbean cat-file -p <hash>
gitbean add test.txt