A C++ implementation of Git's core functionality, originally ported from a Java "gitlet" project. This is a fully functional version control system that handles repositories, commits, branches, merging, and more.
Currently tested and working on macOS. Windows and Linux support coming soon.
TODO: Add Windows and Linux compatibility
cmake -B build && make -C build# Build first
cmake -B build && make -C build
# Install to system PATH
sudo cp build/gitcpp /usr/local/bin/# Add to your ~/.zshrc or ~/.bashrc
export PATH="$PATH:/path/to/git_cpp/build"After installation:
gitcpp <command> [args...]Or without installation:
./build/gitcpp <command> [args...]init- Initialize a new repositoryadd <file>- Stage files for commitcommit <message>- Create a new commitrm <file>- Remove files from staging and working directorystatus- Show repository status
log- Show commit history for current branchglobal-log- Show all commits across all branchesfind <message>- Find commits by message
branch <name>- Create a new branchswitch <name>- Switch to a branchrm-branch <name>- Delete a branchmerge <branch>- Merge another branch into current branch
restore <file>- Restore files from commitsreset <commit>- Reset to a specific commit
config <key> <value>- Set configuration valuesgitcpp config user.name "Your Name"gitcpp config user.email "your@email.com"
Create a .gitcppignore file in your repository root to ignore files and directories:
*.log
temp/
build/
.DS_Store
Supports basic patterns:
*.extension- Ignore all files with specific extensiondirectory/- Ignore entire directoriesfilename- Ignore specific files
When merging branches with conflicting changes, gitcpp will create conflict markers in affected files:
<<<<<<< HEAD
Current branch content
=======
Other branch content
>>>>>>> branch_name
Resolve conflicts by editing the file, then add and commit the resolved version.
gitcpp stores all data in a .gitcpp/ directory:
commits/- Commit objectsblob_files/- File content storageheads/- Branch pointersstaged_files/- Staging areaconfig/- Configuration files
Try this 5-minute walkthrough to see gitcpp in action:
# Build the project
cmake -B build && make -C build
# Create a test directory
mkdir gitcpp_demo && cd gitcpp_demo
# Initialize repository
../build/gitcpp init
# Set up user info
../build/gitcpp config user.name "Demo User"
../build/gitcpp config user.email "demo@example.com"
# Create and add a file
echo "Hello gitcpp!" > hello.txt
../build/gitcpp add hello.txt
../build/gitcpp commit "Initial commit"
# Create a branch and make changes
../build/gitcpp branch feature
../build/gitcpp switch feature
echo "Feature branch changes" >> hello.txt
../build/gitcpp add hello.txt
../build/gitcpp commit "Add feature"
# Switch back and merge
../build/gitcpp switch main
../build/gitcpp merge feature
# Check the result
../build/gitcpp log
cat hello.txtExpected output: You should see both commits in the log and the merged content in hello.txt.
# Create files to ignore
echo "debug info" > debug.log
mkdir temp && echo "temp file" > temp/cache.txt
# Create ignore file
echo "*.log" > .gitcppignore
echo "temp/" >> .gitcppignore
# Check status - ignored files won't show up
../build/gitcpp statusThe project includes Google Test-based unit tests to verify functionality:
# Build tests (included in main build)
cmake -B build && make -C build
# Run tests (work in progress - some tests need isolation fixes)
./build/tests/gitcpp_testsNote: Test suite is currently being refined to properly isolate test environments.