author: Annetta Zheng
This class stores a file
- String _fileid: sha-1 of a file
- byte[] _bytes: the contents of a file
- String _name: name of a file
- String _content: content of a file as a String
- File _file: the file
This class stores a branch-commits tree of a Git Instance
- String _branch: branch name
- ArrayList _commit: commits chain under the branch
This class stores an instance of a commit holding files (saving the contents of entire directories of files.)
- String _msg: the commit message
- byte[] _ts: timestamp of the commit
- String _branch: name of the commit branch
- TreeMap<String, Blobs> _blobs: commited files in the commit
- Commits _parent: the commit's parent (previous commit)
- Commits _parent2: the commit's second parent (previous commit)
- String _id: sha-1 of the commit
This class stores all the information of a Gitlet repository holding commits
- Commits _head: head of the repository
- String _curbranch: current branch
- TreeMap<String, Commits> _allcommits: all commits in the repository
- TreeMap<String, Blobs> _staged: files staged for addition
- TreeMap<String, Blobs> _removed: files staged for removal
This class is the driver class for Gitlet that runs Gitlet through Gitlet, Commits, and Blobs. Implements the commands in Algorithms.
- init
- Creates a new Gitlet version-control system in the current directory.
- add
- Adds a copy of the file as it currently exists to the staging area
- commit
- Saves a snapshot of tracked files in the current commit and staging area so they can be restored at a later time, creating a new commit.
- rm
- Unstage the file if it is currently staged for addition.
- log
- Viewing the history of your backups.
- Starting at the current head commit, display information about each commit backwards along the commit tree until the initial commit, following the first parent commit links, ignoring any second parents found in merge commits.
- global-log
- Like log, except displays information about all commits ever made.
- find
- Prints out the ids of all commits that have the given commit message, one per line.
- status
- Displays what branches currently exist, and marks the current branch with a *. Also displays what files have been staged for addition or removal.
- checkout
- Restoring a version of one or more files or entire commits. Takes in FILES and overwrites the version of the FILES
- branch
- Maintaining related sequences of commits, called branches.
- Creates a new branch with the given name, and points it at the current head node.
- rm-branch
- Deletes the branch with the given name.
- reset
- Checks out all the files tracked by the given commit. Removes tracked files that are not present in that commit. Also moves the current branch's head to that commit node.
- merge
- Merging changes made in one branch into another. Merges files from the given branch into the current branch.
- Checking if a merge is necessary.
- Determining which files (if any) have a conflict.
- Representing the conflict in the file.
- add-remote
- Saves the given login information under the given remote name. Attempts to push or pull from the given remote name will then attempt to use this .gitlet directory.
- rm-remote
- Remove information associated with the given remote name. The idea here is that if you ever wanted to change a remote that you added, you would have to first remove it and then re-add it.
- push
- Attempts to append the current branch’s commits to the end of the given branch at the given remote.
- fetch
- Brings down commits from the remote Gitlet repository into the local Gitlet repository.
- Copies all commits and blobs from the given branch in the remote repository into a branch named [remote name]/[remote branch name] in the local .gitlet, changing [remote name]/[remote branch name] to point to the head commit. This branch is created in the local repository if it did not previously exist.
- pull
- Fetches branch [remote name]/[remote branch name] as for the fetch command, and then merges that fetch into the current branch.
By starting up the program java gitlet.Main init
, it will create a repo directory and an initial commit through the command init().
Based on the command run, structure of files will be saved.
All other commands:
1. java gitlet.Main add [file name]
2. java gitlet.Main commit [message]
3. java gitlet.Main rm [file name]
4. java gitlet.Main log
5. java gitlet.Main global-log
6. java gitlet.Main find [commit message]
7. java gitlet.Main status
8. java gitlet.Main checkout -- [file name]
9. java gitlet.Main checkout [commit id] -- [file name]
10. java gitlet.Main checkout [branch name]
11. java gitlet.Main branch [branch name]
12. java gitlet.Main rm-branch [branch name]
13. java gitlet.Main reset [commit id]
14. java gitlet.Main merge [branch name]
15. java gitlet.Main add-remote [remote name] [name of remote directory]/.gitlet
16. java gitlet.Main rm-remote [remote name]
17. java gitlet.Main push [remote name] [remote branch name]
18. java gitlet.Main fetch [remote name] [remote branch name]
19. java gitlet.Main pull [remote name] [remote branch name]