gvcs is a version control system written in Go, implementing core Git-like functionality.
It's a learning project that demonstrates how version control systems work under the hood, providing commands for repository management, object storage, commits, branches, and more.
This is not even a minimum viable product (MVP). There are no tests, and there's no guarantee that something won't go wrong. Use at your own risk, especially in production environments.
- Educational — Learn how Git works internally by examining the Go implementation
- Portable — Single binary written in Go for easy distribution
- Git-compatible — Implements core Git commands and data structures
- Simple — Focused on core VCS concepts without the complexity of Git's full feature set
You can install gvcs using Go's package manager:
go install github.com/Notwinner0/gvcs/cmd/gvcs@latestMake sure your $GOPATH/bin is in your $PATH.
Clone the repository and build:
git clone https://github.com/Notwinner0/gvcs.git
cd gvcs
go build -o gvcs ./cmd/gvcsThe binary will be created in the current directory.
Initialize a new gvcs repository:
mkdir my-project
cd my-project
gvcs initAdd a file and commit:
echo "Hello, World!" > hello.txt
gvcs add hello.txt
gvcs commit -m "Initial commit"View the commit history:
gvcs loggvcs init [-p path]Creates a new gvcs repository in the specified path (defaults to current directory).
gvcs add -f <files...>Adds file contents to the index.
gvcs commit -m "commit message"Records changes to the repository with the given message.
gvcs log [-c commit]Displays the history of a given commit (defaults to HEAD).
gvcs cat-file -t <type> -o <object>Displays the content of a repository object.
gvcs hash-object [-w] [-t <type>] <file>Computes the object ID for a file and optionally writes it to the database.
gvcs statusShows the working tree status.
gvcs ls-files [-v]Lists all the staged files (use -v for verbose output).
gvcs ls-tree [-r] <tree-ish>Pretty-prints a tree object (use -r to recurse into sub-trees).
gvcs show-refLists references.
gvcs tag [-a] [-n <name>] [-o <object>]Lists and creates tags (use -a for annotated tags).
gvcs rev-parse [-t <type>] <name>Parses revision (or other objects) identifiers.
gvcs rm <files...>Removes files from the working tree and the index.
gvcs check-ignore <paths...>Checks path(s) against ignore rules.
gvcs supports the following commands:
init— Initialize a new, empty repositoryadd— Add file contents to the indexcommit— Record changes to the repositorylog— Display history of a given commitstatus— Show the working tree statusls-files— List all the staged filesls-tree— Pretty-print a tree objectcat-file— Provide content of repository objectshash-object— Compute object ID and optionally creates a blob from a filecheckout— Checkout a commit inside of a directoryshow-ref— List referencestag— List and create tagsrev-parse— Parse revision (or other objects) identifiersrm— Remove files from the working tree and the indexcheck-ignore— Check path(s) against ignore rules
For detailed usage of each command, run gvcs <command> --help.
# Initialize repository
gvcs init
# Create and add a file
echo "content" > file.txt
gvcs add file.txt
# Commit the changes
gvcs commit -m "Add file.txt"
# View history
gvcs log# Compute hash of a file
gvcs hash-object file.txt
# Store the file in the database
gvcs hash-object -w file.txt
# View the stored object
gvcs cat-file -t blob -o <hash># Create a tag
gvcs tag -a -n v1.0 -o HEAD
# List tags
gvcs tag
# Checkout a specific commit
gvcs checkout <commit-hash> <directory>Contributions are welcome! Please feel free to submit issues and pull requests.
To build and test:
go build ./...
go test ./...The MIT License (MIT)
Copyright (c) 2025 Notwinner
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.