This is our implementation of git using C and C++. We have implemented the following commands (flags not included):-
- init
- add
- commit
- branch
- checkout
- merge
- log
- reflog
- stash
- reset
- included support for ".gitignore" file
Everything in git is stored in form of objects. There are mainly 3 types of objects:-
- blob
- tree
- commit
Initialise a new git repository
File to represent the staging area
Commit the changes in staging area. A new commit object and tree structure is created accordingly.
Create a new branch, if not specified print all branches
Stash the contents of staging area if we do not want to commit
stash
stash pop
Merge the contents of current branch with the branch specified
Fast Forward Merge
Three Way Merge
Gives the information about all the commits done by the user of current branch.
Gives information about merges, checkouts, commits done by user till that point.
git clone https://github.com/UrvishkumarPatel/mygit.git
make
- mygit init :-Initialises a new git reposistory.
- mygit add <dir/file>:-Adds the file in the stagging area(Index file).
- mygit commit -m "commit message":-Commits the added file with the message given.
- mygit branch <branch_name>:- Creates a new branch with branch name.
- mygit checkout <branch_name>:- Checkouts to the branch specified.
- mygit merge <branch_name>:- Merges current branch with specified branch.
- mygit log <branch_name>:- Gives the information about all the commits done by the user of current branch.
- mygit reflog <branch_name>:-Gives information about merges, checkouts, commits done by user till that point.
- mygit stash -m "commit message":- Stash the contents of the staging area, commit is not required after that.
Files specified in .gitignore are ignored while adding and commiting.