This package provides Git integration utilities for the Commit Generator project. It enables checking repository status, managing commits, viewing logs, and handling diffs.
To use this package in your project, install it as a dependency:
pnpm install @commit-generator/git
- Checking if the current directory is a Git repository
import { git } from '@commit-generator/git';
if (git.isRepository()) {
console.log('This is a Git repository');
} else {
console.log('Not a Git repository');
}
- Viewing unstaged/staged changes with
diff
const diffOutput = git.diff({ staged: false });
console.log(diffOutput);
- Committing changes
git.commit('Initial commit');
- Amending the last commit
git.amend('Updated commit message');
- Viewing commit logs
const logs = git.log(5);
console.log(logs);
- Adding all changes to staging
git.add();
This package is licensed under the MIT License.