GIT Development Log
Special thanks to Nikita for the excellent tutorial: https://www.leshenko.net/p/ugit
https://deepwiki.com/ReZeroS/git/1-overview
I've compiled useful reference materials in the ./doc directory. Additionally, these resources may be helpful:
- Nick Butler: A concise overview of diff algorithms
- jcoglan: Detailed explanation of the Myers diff algorithm
- Visualization: Helpful tool for visualizing and debugging diff algorithms
- PDF: A brief pdf about Git that you might find interesting
If you're interested in this project, feel free to share your ideas in the discussion forum or contact me via email.
alias zit='java -jar ../zit-1.0-SNAPSHOT-shaded.jar'- Create an alias for the zit executable- On Windows, add this to
C:\Program Files\Git\etc\profile.d\aliases.sh
- On Windows, add this to
zit init- Initialize the.zitdirectory with anobjectssubdirectory, create an index file (staging area), and set up the defaultmainbranch- The default HEAD file contains:
ref: ref/heads/main
- The default HEAD file contains:
zit hash-object file- Accepts a file path
- Reads the file content
- Hashes the content using SHA-1
- Stores the file at
.ugit/objects/{SHA-1-hash}
zit cat-file hash [object|tree|commit|...type]- Display file contentzit write-tree- Generate a tree structure representing the entire repository- Typically used after the
addcommand to create a tree from the index file
- Typically used after the
zit read-tree hash- Warning: This will remove existing content before reading
- Use
cat-fileto locate theroottree write-treelogs can also help identify all trees
While
write-treecaptures snapshots, it lacks contextual information. Usezit commit -m "message"for proper versioning- Check commit content with
cat-file hash commit-id HEADrecords commits with parent information
- Check commit content with
Use
logto view commit history after making commitsCheckout: Select a commit ID from
logto restore that state- [Fixed with getBytes(Charsets.UTF_8)] Bug: Chinese file/directory names previously displayed incorrectly
- Accepts head alias, hash, or ref (branch, tags, HEAD, etc.)
tagcreates an alias for a commit ID, introducing a core Git concept- The git-ref documentation provides essential reference knowledge
TODO: Implement
zit lggraph visualization using Graphvizzit branch name [id]- Create branches as in standard Git- All refs under
refs/headsare treated as branches - File content is simply the commit ID, defaulting to HEAD
- All refs under
zit showdisplays detailed changes using diff, whilestatusshows summary informationzit addstages files or directories in.zit/indexzit commitinvokeswrite-treeand updates the HEAD pointer to the new commit ID- First use creates the default
mainbranch and updates HEAD - Removes MERGE_HEAD and includes message in commit
- First use creates the default
zit statusshows the current repository state- Displays current branch (unless in detached HEAD state)
- Shows merge hash ID during merge operations
- Lists changes to be committed (diff between HEAD tree and index)
- Lists unstaged changes (diff between index and working tree)
zit diffimplements the Myers diff algorithm without linear space refinementzit resetmoves HEAD to the specified commit (difference fromcheckoutpending implementation)zit mergechecks if the merge base equals HEAD, using fast-forward merge when possible- Fast-forward requires no additional commit
- Otherwise uses diff3 to merge the base, HEAD tree, and other tree
- Leaves
merge_headin the zit root directory, requiring manual commit zit merge-basehelps find the common ancestor commit for merging and debugging
zit fetchandzit pushdownload/upload objects and update references
- Implemented diff (Myers algorithm without linear space optimization) and merge (simple diff3) algorithms instead of relying on Unix tools
- While
Ugituses Pythonic code, zit aims to provide code that's easily understandable for developers from various language backgrounds
- Enhance
git hash-objectto match real Git behavior:- Write object size to file
- Compress objects
- Distribute objects across 256 directories to avoid performance issues with large file counts