Meet baseGit, a lightweight Git implementation in JavaScript that provides a simplified version of Git functionality for educational purposes. It allows you to create repositories, branches, commit changes, and switch between branches.
- Repository Management: Generate secure public-private key pairs for wallet management.
- Committing Changes: Sign and verify transactions securely using cryptographic functions.
- Branching and Checkout: Mine blocks with proof-of-work and validate transactions for added security.
Clone the repository to your local machine:
git clone https://github.com/<your-username>/baseGit.git
Navigate to the project directory:
cd baseGit
To use baseGit in your project, include the git.js file:
const Git = require('./git.js');
// Create a new repository
const repo = new Git("myRepo");
// Commit changes
const firstCommit = repo.commit("Initial commit");
// Create and switch to a new branch
repo.checkout("feature-branch");
// Commit changes on the new branch
const secondCommit = repo.commit("Implement feature");
// Switch back to the master branch
repo.checkout("master");
Check the functionality of baseGit using the provided testGit.js file:
const Git = require('./git.js');
const repo = new Git("test");
repo.commit("Initial commit");
console.assert(repo.HEAD.name === "master"); // Should be on master branch.
repo.checkout("testing");
console.assert(repo.HEAD.name === "testing"); // Should be on the new testing branch.
repo.checkout("master");
console.assert(repo.HEAD.name === "master"); // Should be on the master branch.
repo.commit("second commit");
repo.checkout("testing");
console.assert(repo.HEAD.name === "testing"); // Should be on the testing branch again.
Contributions are welcome! If you have ideas for improvements, new features, or bug fixes, please open an issue or submit a pull request.