https://github.com/dmitrii-artuhov/mini-git
Git replica with basic functionality of the version control system
https://github.com/dmitrii-artuhov/mini-git
Last synced: about 1 month ago
JSON representation
Git replica with basic functionality of the version control system
- Host: GitHub
- URL: https://github.com/dmitrii-artuhov/mini-git
- Owner: dmitrii-artuhov
- Created: 2023-09-18T04:34:58.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-09-18T05:34:32.000Z (about 2 years ago)
- Last Synced: 2025-03-13T18:23:52.863Z (7 months ago)
- Language: Java
- Size: 74.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# MiniGit
This is a toy git replica that is build according to the actual git specification.
## Functionality
* `init` - initializing the repository
* `add ` - adding a file
* `rm ` - the file is deleted from the repository, physically remains
* `status` - modified/deleted/not added files
* `commit ` with date and time
* `reset ` - the behavior of `reset` is the same as `git reset --hard`
* `log [from_revision]`
* `checkout `
* Possible values of `revision`:
* `commit hash` - hash of the commit
* `master` - return the branch to its original state
* `HEAD~N`, where `N` is a non-negative integer. `HEAD~N` means the n-th commit before HEAD (`HEAD~0 == HEAD`)
* `checkout - ` - resets changes in files
* `branch-create ` - create a branch named ``
* `branch-remove ` - remove branch ``
* `show-branches` - show all available branches## Implementation insights
The mini-git repository is stored as a tree data structure. There is a couple of file types that I used (git also uses them) that are related to this tree abstraction and to the mini-git implementation in general:
- `BlobFile`: these are actual files that are added to the repository.
- `TreeFile`: in order to reuse some files from previous commits we add edges to the our tree abstraction. The edges are represented by this file type.
- `CommitFile`: this is the commit file, it stores the hash of the root `TreeFile`. By traversing the tree starting at this root node we are able to extract all files that are related to the particular commit.
- There are some other files like `IndexFile`, `HeadFile`, and `BranchFile`: the last two store the current commit hash and current branch, respectively. Index file allows to stage new and updated files and compare them to those that are already commited.You can get more insights from these articles:
- https://habr.com/ru/articles/313890/ (this one in russian, but you can translate the webpage)
- https://git-scm.com/book/en/v2 (chapter 10, "Git Internals")