Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on:
pull_request:
push:
branches:
- main

permissions:
contents: read

jobs:
test:
name: Go test
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false

- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
cache: false

- name: Build
run: go build ./...

- name: Test
run: go test ./...
27 changes: 27 additions & 0 deletions .github/workflows/zizmor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: GitHub Actions Security

on:
pull_request:
push:
branches:
- main

permissions:
contents: read

jobs:
zizmor:
name: zizmor
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false

- name: Run zizmor
uses: zizmorcore/zizmor-action@5f14fd08f7cf1cb1609c1e344975f152c7ee938d # v0.5.6
with:
advanced-security: false
inputs: .github/workflows
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/ghost-commit
*.exe
30 changes: 30 additions & 0 deletions Formula/ghost-commit.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class GhostCommit < Formula
desc "Commit virtual file contents without changing the working tree"
homepage "https://github.com/s4na/ghost-commit"
license "MIT"
head "https://github.com/s4na/ghost-commit.git", branch: "main"

depends_on "go" => :build

def install
system "go", "build", *std_go_args(ldflags: "-s -w")
end

test do
mkdir testpath/"repo" do
system "git", "init"
system "git", "config", "user.name", "Homebrew Test"
system "git", "config", "user.email", "homebrew@example.test"

(testpath/"repo/base.txt").write "base\n"
system "git", "add", "base.txt"
system "git", "commit", "-m", "initial"

(testpath/"ghost.txt").write "ghost\n"
assert_match(/^[0-9a-f]{40}$/,
shell_output("#{bin}/ghost-commit -m 'ghost file' --file virtual.txt=#{testpath}/ghost.txt").strip)
assert_equal "ghost\n", shell_output("git show HEAD:virtual.txt")
refute_path_exists testpath/"repo/virtual.txt"
end
end
end
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 s4na

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
47 changes: 47 additions & 0 deletions README.ja.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# ghost-commit

[English](README.md)

`ghost-commit` は、実際のファイルを書き換えずに「別の内容のファイル」をコミットできる CLI です。

LLM が作った中間ファイルや、まだ作業ツリーに存在しないファイルを、そのまま指定したパスの内容としてコミットできます。

## Install

Homebrew でインストールできます。

```sh
brew tap s4na/ghost-commit https://github.com/s4na/ghost-commit
brew install --HEAD ghost-commit
```

## Usage

別ファイルの内容を `README.md` としてコミットします。

```sh
ghost-commit -m "README を更新" --file README.md=/tmp/llm-readme.md
```

標準入力から受け取った内容を、新しいファイルとしてコミットします。

```sh
cat /tmp/generated-config.yml | ghost-commit -m "設定を追加" --file config.yml=-
```

ファイルが存在しない状態もコミットできます。

```sh
ghost-commit -m "古い設定を削除" --delete old-config.yml
```

`ghost-commit` は指定された仮想ファイルだけをコミットします。手元のファイルや、指定していない staging 済みの変更は変更しません。

コミット後に、手元のファイルが ghost commit の内容と違う場合は `git status` に差分として表示されます。これはファイルを書き換えたわけではなく、新しいコミットの内容と手元の状態が違うためです。

## Build from source

```sh
go build -o ghost-commit .
./ghost-commit --help
```
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,47 @@
# ghost-commit
# ghost-commit

[日本語](README.ja.md)

`ghost-commit` is a CLI for committing alternate file contents without rewriting the actual files in your working tree.

It lets you commit intermediate files produced by an LLM, or files that do not exist in your working tree yet, as content at the paths you choose.

## Install

Install with Homebrew:

```sh
brew tap s4na/ghost-commit https://github.com/s4na/ghost-commit
brew install --HEAD ghost-commit
```

## Usage

Commit another file's contents as `README.md`.

```sh
ghost-commit -m "Update README" --file README.md=/tmp/llm-readme.md
```

Commit content from stdin as a new file.

```sh
cat /tmp/generated-config.yml | ghost-commit -m "Add config" --file config.yml=-
```

Commit a state where a file does not exist.

```sh
ghost-commit -m "Remove old config" --delete old-config.yml
```

`ghost-commit` commits only the virtual files you specify. It does not rewrite your working files or alter unrelated staged changes.

After a ghost commit, `git status` may show differences if your working files differ from the new commit. That happens because the commit changed, not because `ghost-commit` rewrote those files.

## Build from source

```sh
go build -o ghost-commit .
./ghost-commit --help
```
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/s4na/ghost-commit

go 1.26.1
Loading