Gitlet is a simplified version-control system inspired by Git, implemented in Java as part of the UC Berkeley CS61B course. It supports basic version control operations such as add, commit, branch, checkout, merge, and more, for flat file structures.
- Initialize a repository
- Add and remove files
- Commit changes
- Branch management (create, delete, switch)
- Checkout files and branches
- Merge branches (with basic conflict handling)
- Log and global log
- Status display
- Reset to previous commits
proj2/
├── gitlet/ # Main source code (Java)
├── testing/ # Test code and scripts
├── images/ # Project diagrams and flowcharts
└── gitlet-design/
├── gitlet-design_en.md # English design doc
└── gitlet-design_cn.md # Chinese design doc
- Java 8 or above
- (Optional) JUnit for testing
In the proj2
directory, run:
javac gitlet/*.java
To use Gitlet, run:
java gitlet.Main <command> [args]
For example:
java gitlet.Main init
java gitlet.Main add file.txt
java gitlet.Main commit "Initial commit"
See the testing/
directory for test scripts and sample test cases. You can use the provided Makefile
for automated testing:
cd testing
make test
For detailed design, implementation ideas, and diagrams, please refer to the above documents.
-
This is a project for UC Berkeley CS61B. Project spec: https://sp21.datastructur.es/materials/proj/proj2/proj2#global-log
-
For storage design and file structure, also refer to the official git documentation: https://www.progit.cn/#_plumbing_porcelain