/rit

Implementation of Git in Rust

Primary LanguageRustMIT LicenseMIT

rit

GitHub Actions workflow badge

Implementation of Git in Rust

Environment

  • Rust 1.69.0

Note

About Git

Directory structure of .git when you execute git init

$ git init
$ tree -L 2 .git
.git
├── HEAD
├── config
├── description
├── hooks
├── info
├── objects
│   ├── info
│   └── pack
└── refs
    ├── heads
    └── tags

Essential files and directories of Git

Essential files and directories of Git in .git directory are as follows:

  • objects
    • A directory that stores all contents (text / binary files) managed by Git
  • HEAD
    • A text file that points to the current branch. A content of HEAD contains file path to files in refs directory.
  • refs
    • A directory that stores pointers (branch / tag) that point to commit objects in contents. A content of refs directory is as follows:
      • heads
        • A directory that stores pointers (branch) that point to commit objects in contents
      • tags
        • A directory that stores pointers (tag) that point to commit objects in contents
  • index
    • A file that stores the information of the staging area

commands of cargo

# rustc
rustc main.rs
./main
rustc main.rs -o bin/rit
./bin/rit

# cargo
cargo new [project name]
cargo init
cargo build           # build for development (no optimization, fast build time, slow runtime)
cargo build --release # build for release (optimization, slow build time, fast runtime)
cargo run
cargo run --release
cargo check
cargo update
cargo test

References