This project is a simplified version of the Git version control system. It allows you to initialize a new repository, create and delete references, add files to the staging area, list and clear the staging area, and create new commits. You can also merge references, list the commits of a reference, and display the content of a commit.
The project is implemented in C, no external library is used. The project is divided into several folders:
src
: contains the source code of the project (.c
files)include
: contains the header files of the project (.h
files)doc
: contains the documentation of the project (.html
or.tex
files, the documentation is created using Doxygen)Makefile
: contains the instructions to compile the projectREADME.md
: contains the documentation of the project
The project is divided into several modules, each module is subdivided into several files for better organization:
add
: contains the functions to add files to the staging areabranch
: contains the functions to create and delete branchescheckout
: contains the functions to switch branchescommit
: contains the functions to create and display commitsinit
: contains the functions to initialize a new repositorylibs
: contains the functions to manipulate the files and the stringscell
: contains the functions to manipulate the cells of a linked listcommit
: contains the functions to manipulate the commitsfile
: contains the functions to manipulate the files, create a blob, manage the permissions, and the file modehash
: contains the functions to manipulate the hash of a file and a commitkey_val
: contains the functions to manipulate the key-value pairslist
: contains the functions to manipulate the linked lists with the different types of datawork_file
: contains the functions to manipulate the working fileswork_tree
: contains the functions to manipulate the working tree (based on thework_file
module)
merge
: contains the functions to merge branchesmygit
: contains the functions to manage the project and the user interfaceref
: contains the functions to manipulate the referencesutils
: contains some useful functions
To compile the project, you need to run the following command:
make
make clean
To execute the project, you need to run the following command:
./mygit.out <command> <args>
init
: initialize a new repositorylist-refs
: list all the referencescreate-ref
: create a new referenceref
: the name of the referencehash
: the hash of the commit
delete-ref
: delete a referenceref
: the name of the reference
add
: add a file to the staging areafile
: the name of the file[<file1>, <file2>, ...]
: the name of the files (optional)
list-add
: list all the files in the staging areaclear-add
: clear the staging areacommit
: create a new commitbranch
: the name of the branch-m <message>
: the message of the commit (optional)
2022-2023