Gitlet / README.md
README.md
Raw

Gitlet

Implemented my own version-control system that mimics the basic features of Git. The internal structure of the software included blobs (saved content of the files), trees (directory structures mapping names to references to blobs and other trees), and commits (combinations of log messages, other metadata (commit date, author, etc.), a reference to a tree, and references to parent commits). Used cryptographic hash functions like SHA-1, serialization, directory manipulation, graph traversals, and integration tests. The application was built with Java.

Methods

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. The commit is said to be tracking the saved files.

rm

Unstage the file if it is currently staged for addition.

log

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. If there are multiple such commits, it prints the ids out on separate lines.

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

Can do 3 different functions depending on the command:

  • Takes the version of the file as it exists in the head commit, the front of the current branch, and puts it in the working directory, overwriting the version of the file that's already there if there is one. The new version of the file is not staged.
  • Takes the version of the file as it exists in the commit with the given id, and puts it in the working directory, overwriting the version of the file that's already there if there is one. The new version of the file is not staged.
  • Takes all files in the commit at the head of the given branch, and puts them in the working directory, overwriting the versions of the files that are already there if they exist. Also, at the end of this command, the given branch will now be considered the current branch (HEAD). Any files that are tracked in the current branch but are not present in the checked-out branch are deleted. The staging area is cleared, unless the checked-out branch is the current branch (see Failure cases below). ###branch Creates a new branch with the given name, and points it at the current head node. A branch is nothing more than a name for a reference (a SHA-1 identifier) to a commit node. ###rm-branch Deletes the branch with the given name. This only means to delete the pointer associated with the branch; it does not mean to delete all commits that were created under the branch, or anything like that. ###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 Merges files from the given branch into the current branch.