Generate updates.txt, updates.json, and updates.rss from Git commits at build time.
This tool helps you create and maintain update logs for your project based on Git commit history. It's particularly useful for web projects where you want to display a changelog or updates page.
- Automatic detection of framework-specific output directories
- Filtering of commits (ignores merge, chore, ci, build, refactor by default)
- Multiple output formats: text, JSON, and RSS
- Keeps track of processed commits to avoid duplicates
- Works with all major JavaScript frameworks (Next.js, Remix, Astro, etc.)
- Option to strip branch names from commit messages
- Redact or hide confidential terms from commit messages
- Dynamic API endpoints for serving updates directly from your webapp
npm i -D git2feed
yarn add -D git2feed
pnpm add -D git2feedAdd this to your build script:
npx git2feed # npm
yarn git2feed # yarn
pnpm exec git2feed # pnpmAdd these scripts to your package.json for easy local development:
"scripts": {
"g2f": "pnpm exec git2feed --f --confidential 'shadcdn,daisyui,aws' --strip-branch --f",
"updates": "pnpm exec git2feed",
"updates:strip": "pnpm exec git2feed --strip-branch",
"updates:recent": "pnpm exec git2feed --since \"1 week ago\"",
"prepare": "pnpm exec git2feed --strip-branch"
}The prepare script will automatically run when you run npm install in your project, ensuring your update files are always generated before commits.
git2feed can now provide dynamic API endpoints that serve your updates directly from your web application without requiring pre-generated files.
npx git2feed install-endpoint # npm
yarn git2feed install-endpoint # yarn
pnpm exec git2feed install-endpoint # pnpmThis will automatically detect your framework (Next.js, Express, SvelteKit, Astro, Nuxt) and set up the appropriate endpoints.
If you don't want to rely on a local Git repository, you can configure git2feed to fetch commits directly from GitHub's API.
Set the following environment variables in your .env file:
GITHUB_TOKEN=your_personal_access_token
GITHUB_OWNER=your_github_username_or_org
GITHUB_REPO=your_repository_name
For GitHub tokens, you need to create a personal access token with the repo scope.
After setting up, your updates are available at:
/api/git2feed/txt- Plain text format/api/git2feed/json- JSON format/api/git2feed/rss- RSS feed format
You can force a refresh of the cached data by adding the refresh=true query parameter:
/api/git2feed/json?refresh=true
git2feed automatically installs a git pre-commit hook when you install the package. This hook:
- Runs git2feed before every commit
- Adds the generated files to the commit
This ensures your update files are always up-to-date with your latest commits.
If you need to manually install the git hook:
npx git2feed install # npm
yarn git2feed install # yarn
pnpm exec git2feed install # pnpm
# Alternative method:
npm run install-hooks # npm
yarn install-hooks # yarn
pnpm run install-hooks # pnpmYou can customize the git hook by creating a .git2feed file in your project root. This is a JSON file with the following options:
{
"command": "npx git2feed --strip-branch --confidential 'secret,private'",
"outputFiles": [
"public/updates.txt",
"public/updates.rss",
"public/updates.json",
"public/updates.index.json"
],
"addToCommit": true,
"hookMessage": "# Hook git2feed personnalisé"
}Available options:
| Option | Type | Default | Description |
|---|---|---|---|
command |
string | "npx git2feed" |
The command to run before commit |
outputFiles |
string[] | ["public/updates.txt", "public/updates.rss", "public/updates.json", "public/updates.index.json"] |
Files to add to the commit |
addToCommit |
boolean | true |
Whether to automatically add generated files to the commit |
hookMessage |
string | "# Hook généré automatiquement par git2feed" |
Comment message in the hook file |
After modifying the configuration, run npm run install-hooks to update the git hook.
Then you can run them as needed:
# Basic update generation
npm run updates
# Strip branch names from commit messages
npm run updates:strip
# Only process commits from the last week
npm run updates:recentnpx git2feed --since "1 month ago" # npm
yarn git2feed --since "1 month ago" # yarn
pnpm exec git2feed --since "1 month ago" # pnpmnpx git2feed --max 10 # npm
yarn git2feed --max 10 # yarn
pnpm exec git2feed --max 10 # pnpmnpx git2feed --out ./static/updates # npm
yarn git2feed --out ./static/updates # yarn
pnpm exec git2feed --out ./static/updates # pnpmnpx git2feed --strip-branch # npm
yarn git2feed --strip-branch # yarn
pnpm exec git2feed --strip-branch # pnpmnpx git2feed --site https://example.com # npm
yarn git2feed --site https://example.com # yarn
pnpm exec git2feed --site https://example.com # pnpmnpx git2feed --keep "(feature|fix)" # npm
yarn git2feed --keep "(feature|fix)" # yarn
pnpm exec git2feed --keep "(feature|fix)" # pnpmnpx git2feed --confidential "aws,s3,daisyui,api key,secret token" # npm
yarn git2feed --confidential "aws,s3,daisyui,api key,secret token" # yarn
pnpm exec git2feed --confidential "aws,s3,daisyui,api key,secret token" # pnpmNote: Spaces within terms are preserved. For example,
"api key"will be treated as a single term.
npx git2feed --hide "secret,password,key,private token" # npm
yarn git2feed --hide "secret,password,key,private token" # yarn
pnpm exec git2feed --hide "secret,password,key,private token" # pnpmNote: Spaces within terms are preserved. For example,
"private token"will be treated as a single term.
npx git2feed --force # npm
yarn git2feed --force # yarn
pnpm exec git2feed --f # pnpm (using shorthand)npx git2feed --site https://example.com --max 50 --strip-branch --since "2 weeks ago" --confidential "aws,api-key" # npm
yarn git2feed --site https://example.com --max 50 --strip-branch --since "2 weeks ago" --confidential "aws,api-key" # yarn
pnpm exec git2feed --site https://example.com --max 50 --strip-branch --since "2 weeks ago" --confidential "aws,api-key" # pnpm"scripts": {
"build": "next build && npx git2feed --strip-branch --site https://mysite.com"
}"scripts": {
"build": "astro build && npx git2feed --max 50 --site https://mysite.com"
}import { generateUpdates } from "git2feed";
async function main() {
const result = await generateUpdates({
siteUrl: "https://example.com",
maxCount: 100,
stripBranch: true,
confidential: "aws,s3,api-key,private token,secret key",
hide: "secret,password,internal code",
force: false, // Set to true to rebuild all files from scratch
});
console.log(`Generated updates in ${result.outDir}`);
}
main().catch(console.error);| Option | CLI Flag | Description | Default |
|---|---|---|---|
| Root Path | --root |
Repository root path | Current directory |
| Output Dir | --out |
Output directory (overrides auto-detection) | Auto-detected |
| Site URL | --site |
Site URL for RSS feed | Empty or from env |
| Max Commits | --max |
Maximum number of commits to process | 2000 |
| Since | --since |
Process commits since date (e.g. "1 week ago") | All commits |
| Keep Pattern | --keep |
Regex pattern for keeping commits | Non-chore/ci/build |
| Strip Branch | --strip-branch |
Remove branch names from commit messages | false |
| Confidential | --confidential |
Replace terms with "--confidential--" (spaces preserved) | None |
| Hide Terms | --hide |
Completely hide terms from messages (spaces preserved) | None |
| Force Regen | --force, --f |
Force regeneration, ignoring previously processed commits | false |
| Help | --help, -h |
Show help | - |
git2feed automatically detects the appropriate output directory based on your project:
- Next.js:
public - Remix:
public - Astro:
public - SvelteKit:
static(falls back topublicif present) - Nuxt 3:
public(Nuxt 2:staticif it exists) - Gatsby:
static(falls back topublicif it exists) - VitePress:
.vitepress/public - Other: picks the first existing among:
public,static,dist/public,build/public,www,web,htdocs,site,app/public; or createspublic.
You can override this by using the --out option.
Three files are generated in the output directory:
updates.txt- A human-readable text file with updates grouped by dateupdates.json- A structured JSON file with the same informationupdates.rss- An RSS feed for subscription
Plus an additional index file:
updates.index.json- Tracks processed commit hashes to avoid duplicates
The project includes comprehensive tests to ensure all features work correctly:
# Run integration tests
npm test
# Run unit tests for text processing functionality
npm run test:unitUnit tests verify:
- Confidential term replacement (with and without spaces)
- Term hiding (with and without spaces)
- Branch name stripping
- Case insensitivity
- Special character handling
Created by Aurélien Rommelaere. Check out more of my projects and tools at arommelaere.com.
MIT