Skip to main content

A lightweight version of Git-like local Version Control System

Project description

GitLite

A lightweight implementation of Git-like local version control system built from scratch in Python, designed to provide deeper understanding of Git's internal workings. Its core functionality revolves around staging and committing files, managing branches, and tracking file changes using SHA-1 hashes.

For more in-depth details on internal working of a version control system, checkout this blog.

Available features and Usage

Install python package

$ pip install gitlite

OR

$ pip install gitlite==0.3.1

gitlite init

Initializes an empty gitlite repository

$ gitlite init

gitlite add

Add files for staging

$ gitlite add <file-name1> <file-name2>

gitlite status

View status of the working directory, including staged, modified, and untracked files.

$ gitlite status

gitlite commit

Creates a snapshot of the repository, storing metadata like timestamps, commit messages, and tree hashes.

  • -m: Commit message
  • -a / --amend : Amend to previous commit
$ gitlite commit -m <commit-message>

Amend to previous commit

$ gitlite commit -a <new-commit-message>

gitlite branch

View, create and modify branches

  • branch_name: Create new branch
  • -m: Rename current branch
  • -d: Delete a branch (other than current branch)

View all branches

$ gitlite branch

Create a branch

$ gitlite branch <branch-name>

Rename a branch

$ gitlite branch -m <new-branch-name>

OR

$ gitlite branch -m <old-branch-name> <new-branch-name>

Delete a branch (other than current branch)

$ gitlite branch -d <branch-name>

gitlite checkout

Switch between branches

  • branch_name: Checkout to a new branch
  • -b: Create new branch and checkout to that branch
$ gitlite checkout <branch-name>

Create a new branch and checkout

$ gitlite checkout -b <new-branch-name>

gitlite log

View commit history of current branch

  • branch_name: View commit history of a particular branch
$ gitlite log <branch-name>

Current branch logs

$ gitlite log

.gitignore Support

Implements .gitignore parsing to exclude specified files from tracking.

Further help

$ gitlite --help

Architecture:

The system utilizes a tree-based structure to represent the file system, with TreeItem objects as nodes. CommitObject instances represent commits, linked to their parent commits and associated tree objects. An index file tracks the staging area. Utility functions provide core operations like SHA-1 hashing, file system traversal, and .gitignore handling.

Technologies Used:

  • Python: The primary programming language.
  • SHA-1: For file hashing and identifying changes in within the file system tree.
  • enum module: For type-safe file type representation (FileType).

Purpose:

The project aims to provide a simplified, educational implementation of core Git concepts, focusing on staging, committing, and branching.

Potential Improvements

Support for following git commands:

  • merge: Merge one branch to another
  • rebase: Change the base of current branch
  • clone: Clone a remote repository
  • push: Push changes to a remote repository
  • pull: Pull changes from a remote repository

Remote Repository Support

Implement the ability to interact with remote repositories (e.g., fetching, pushing). This is a significant undertaking but would greatly enhance GitLite's functionality.

Configuration Management

Implement a more robust configuration management system. This would allow users to customize GitLite's behavior, such as:

  • User Information: Store user name and email address.
  • Core Settings: Store core GitLite settings (e.g., editor, merge tool).
  • Repository-Specific Settings: Store settings specific to a particular repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitlite-0.3.3.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gitlite-0.3.3-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file gitlite-0.3.3.tar.gz.

File metadata

  • Download URL: gitlite-0.3.3.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for gitlite-0.3.3.tar.gz
Algorithm Hash digest
SHA256 6dcacd9204d0b39bedffe5a7ced41504136c804a94be618ea5a4aaabcf44f6fb
MD5 5253d1e2a20ae6a9b3382bf3a89c16f7
BLAKE2b-256 a8460a10ec892585f8215a8f0ad59b02b00407e5900ca5abb1dd38c388fa2376

See more details on using hashes here.

File details

Details for the file gitlite-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: gitlite-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for gitlite-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0ed33541c7cea91ee32c0109b4c242382861f43b778e2a3ea2279ca035eecc9d
MD5 a81990c742f31b71a0267738b0a5b24c
BLAKE2b-256 022cbe4e0f1c90495378450e12acb4482a9c2d6e37723c20b55347cc74c05ea4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page