push-signed-commits

command module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 18 Imported by: 0

README

push-signed-commits

Tool to push a range of commits via the API so they get signed by GitHub.

Features
  • Highly flexible commit selection.
    • Supports pushing a single commit.
    • Supports pushing a range of existing commits using git's native revision syntax.
    • Supports pushing a new commit from the staging area.
  • Guarantees the correctness and fidelity of pushed commits.
    • Supports pushing empty commits.
    • Specifies the expected parent commit while pushing.
    • Will preserve multi-line commit message subjects and bodies.
    • Will refuse to push commits which can't be fully represented via the API, including ones with:
      • Symlink update/creation.
      • Submodule update/creation.
      • Non-regular (i.e., executable) file update/creation.
    • Uses git to do the diffing natively and reads directly from the repository rather than the working directory (unlike a few of the similar alternatives).
      • The contents will be correct.
      • The core.autocrlf option will be applied consistently (since git does it when adding to the index).
      • Uses plumbing commands (e.g., diff-tree vs diff) to avoid being affected by the local git config.
      • Supports unusual filenames with special characters (newlines, tabs, quotes, backslashes, non-printable characters, etc) by using null-terminated output.
  • High-quality implementation:
    • Much more error checking and validation than other similar tools.
    • Minimal implementation.
    • No dependencies other than the native git command
    • 100% hand-coded and tested.
Limitations
  • The createCommitOnBranch GraphQL mutation has some limitations:
    • On the commit:
      • Extremely large commits may fail due to size restrictions in the API.
      • The GraphQL API rate limit applies (unlike regular push operations).
      • Does not support creating new branches, the target branch must already exist.
    • On the commit metadata:
      • The author/commit date will be replaced with the current date.
      • The author will be replaced with the name/email associated with the token's owner.
      • The committer will be replaced with the web flow one (currently GitHub <noreply@github.com>).
      • The commit hash will change (obviously).
    • On the commit contents:
      • Does not support pushing commits with multiple parents (i.e., merge commits).
      • Does not support pushing commits containing changes to non-regular files (e.g., symlinks, submodules, executables).
  • The local repository will not be automatically updated to the newly created commits (if you want that, fetch then do a git reset --soft to the last commit printed).
Compatibility

I'm still deciding what I want the CLI to look like. The arguments and output are subject to change for now, so you should pin to a specific version.

A working version should continue to work indefinitely, as it uses core git functionality and the GitHub API is unlikely to change.

Examples
# create and push a commit directly (and skip it if there aren't any changes to commit)
git add .
go run github.com/pgaskin/push-signed-commits@v0.0.3 -commit username/repo master $'commit message subject\n\ncommit message body'

# create and push a commit using git
git add .
git commit -m 'test commit'
go run github.com/pgaskin/push-signed-commits@v0.0.3 username/repo master HEAD

# push all commits created on the current branch since the last pull
go run github.com/pgaskin/push-signed-commits@v0.0.3 username/repo master HEAD@{u}..HEAD
Alternatives

I made this since the other ones weren't good enough, but here's a list of them anyways:

As of 2026-04-05, most of them don't support pushing a range of existing commits, most of them use the working copy instead of the repository index, most of the git-based ones can't handle filenames with special characters, and none of them verify that all files in the commit can actually be represented properly with the API.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL