P2P git-like file manager.
git2p is a CLI application for synchronizing files between computers directly (peer-to-peer), with a custom change history journal and the ability to revert changes. The project is designed for learning how git and p2p networks work.
First, compile the project:
cargo buildAll subsequent commands should be run from your project's directory using ./target/debug/git2p <command>.
-
Initialize a repository: In your project folder, run the initialization command. This will create a
.git2pdirectory to store versions and logs../target/debug/git2p init
-
Add files for tracking: Add the files you want to track.
./target/debug/git2p add file1.txt file2.txt
-
Commit your changes: Save the state of your tracked files by creating a commit with a message.
./target/debug/git2p commit -m "Your commit message" -
View commit history: To see the list of all commits, use the
logcommand../target/debug/git2p log
-
Revert to a previous version: You can restore the state of your files from a specific commit using its ID.
./target/debug/git2p revert <commit_id>
git2p allows you to synchronize your repository with other peers on the same network. It also automatically remembers peers you've successfully connected to, saving them in a .git2p/known_peers.json file. On startup, and periodically every 30 seconds, it will attempt to reconnect to these known peers to maintain synchronization.
-
Start a node: On the first computer (e.g., in
peer1directory), run theconnectcommand. It will start listening for incoming connections and print its peer ID and listening address.# On Peer 1 ./target/debug/git2p connect -
Connect from another peer: On the second computer (e.g., in
peer2directory), runconnectand provide the address of the first peer. You can also run it without an address to discover peers automatically via mDNS.# On Peer 2 (to connect to a specific address) ./target/debug/git2p connect --addr /ip4/192.168.1.5/tcp/56789 # On Peer 2 (for automatic discovery) ./target/debug/git2p connect
Once connected, the peers will automatically exchange commit information.
-
Pull changes: After making and committing changes on one peer, go to the other peer and run the
pullcommand. This will fetch the latest commit and update your local files.# On the peer that needs to receive changes ./target/debug/git2p pull
init: Initializes a new git2p repository.add <files...>: Adds one or more files to tracking.rm <files...>: Removes one or more files from tracking.commit -m <message>: Records changes to the repository.log: Shows the commit history.list: Lists all tracked files.revert <commit_id>: Reverts the working directory to a specific commit.watch: Watches for changes in tracked files.connect [--addr <multiaddr>]: Connects to the P2P network. Can optionally dial a specific peer address.pull: Fetches the latest commit from the network and applies it to the working directory.
- P2P connection between computers
- Custom change history journal (git-like, but simpler)
- Automatic peer discovery and reconnection
- Beautiful CLI interface
- Ability to revert changes
- (Future) Mobile app for file access
- Repository initialization (
init) - Add files to tracking (
add) - Commit changes (
commit) - View change history (
log) - Revert to previous version (
revert) - File change watching (
watch) - P2P connection between two computers (
connect) - Synchronize changes (
pull) - Colorful CLI interface
- Automatic reconnection to known peers
- Transfer file diffs during synchronization
- Conflict resolver for simultaneous changes
- Mobile app
- Web interface
- MVP: 100%