Cobra is a Git-like version control system implemented in Rust. It provides basic version control functionality similar to Git, allowing you to track changes in your codebase, create commits, and manage your project's history.
Fun Fact: Check out RaphaeleL/jobra for a Java implementation of a version control system!
- Make sure you have Rust and Cargo installed
- Clone this repository
- Build the project:
cargo build --release - The binary will be available at
target/release/cobra
$ cobra -h
A Git-like version control system
Usage: cobra [COMMAND]
Commands:
init Initialize a new repository
clone Clone a repository from a remote
add Add file contents to the index
commit Record changes to the repository
log Show commit logs
status Show the working tree status
branch List, create, or delete branches
stash Stash changes in a dirty working directory
remote Manage remote repositories
push Push changes to a remote repository
pull Pull changes from a remote repository
serve Start a Cobra server
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
Cobra follows Git's internal object model:
- Blob Objects: Store file contents
- Tree Objects: Represent directories and file hierarchies
- Commit Objects: Store commit metadata and point to trees
- References: Track branches and HEAD position
The repository structure is similar to Git:
.cobra/
├── HEAD
├── index
├── objects/
└── refs/
└── heads/
Cobra now supports remote repositories! You can:
- Add remotes:
cobra remote add <name> <url> - List remotes:
cobra remote list - Remove remotes:
cobra remote remove <name> - Push changes:
cobra push <remote> <branch> - Pull changes:
cobra pull <remote> <branch>
# Step 1: Setup in repo1 and push to remote
cd /tmp/cobra/repo1
cobra init
echo "foo" > foo.txt
cobra add foo.txt
cobra commit -m "init"
cobra remote add origin file:///tmp/cobra/remote/
cobra push origin main
# Step 2: Clone from remote into repo2
cd /tmp/cobra
cobra clone file:///tmp/cobra/remote/ repo2
# Step 3: Make changes in repo2 and push back rto remote
cd repo2
echo "modified foo" > foo.txt
cobra add foo.txt
cobra commit -m "modified in repo2"
cobra push origin main
# Step 4: Pull changes from remote back to repo1
cd ../repo1
cobra pull origin mainContributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.
This project is open source and available under the MIT License.