Skip to content

El1Leon/MyGit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyGit

Minimal Git-like implementation in Swift. It supports repo initialization, staging, committing, status, and log, with Git-style object storage and optional compression. Built as a SwiftPM executable for macOS 10.15+.

Features

  • mygit init sets up .mygit/, objects/, refs/, HEAD, and an empty index.
  • mygit add <file> hashes content (SHA-1), stores blobs, and updates the staging index.
  • mygit commit -m "msg" builds trees from the index, links parent commits, records author/committer/timestamps, writes commit objects, and updates refs/HEAD.
  • mygit status shows modified/deleted/untracked files relative to the index.
  • mygit log walks commit history from HEAD and prints commits.
  • Global flags: --verbose for tracing actions, --compress to zlib-compress stored objects.

Requirements

  • macOS 10.15+
  • Swift toolchain with CryptoKit available (Command Line Tools or Xcode)

Building

swift build

Running

From the package root:

# Initialize a repository
.build/debug/MyGit init

# Stage a file
.build/debug/MyGit add path/to/file.txt

# Commit staged changes
.build/debug/MyGit commit -m "Initial commit"

# Inspect status
.build/debug/MyGit status

# View history
.build/debug/MyGit log

Global flags can precede the command:

.build/debug/MyGit --verbose --compress add file.txt

Author/Committer Info

Uses environment variables if set:

  • MYGIT_AUTHOR_NAME, MYGIT_AUTHOR_EMAIL
  • MYGIT_COMMITTER_NAME, MYGIT_COMMITTER_EMAIL Falls back to system user info when unset.

Notes

  • Objects are stored Git-style under .mygit/objects/aa/bb.... Compression is optional.
  • The index is a simple JSON mapping of path → blob hash (staged snapshot).
  • HEAD defaults to refs/heads/main; commits update the branch ref or write directly to HEAD when detached.

About

A Git-like version control system written in Swift.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages