diff --git a/README.md b/README.md index e02ad8b..6390262 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,8 @@ gh commit -B main -A -d | -A | --all | `bool` | Include all tracked files with changes | | -U | --untracked | `bool` | Include untracked files (requires `--all`) | | -d | --dry-run | `bool` | Show which files would be committed, without committing | +| -b | --base-commit | `string` | Specify a specific commit SHA to use as the base for the new commit | +| -f | --allow-fast-forward | `bool` | Allow fast-forward operations when using --base-commit | | -V | --version | `bool` | Show version | | -h | --help | `bool` | Show help text | @@ -80,6 +82,35 @@ Signed commits are automatically created when using GitHub Actions. --- +## 🔄 Base Commit and Fast-Forward + +The `--base-commit` flag allows you to specify a specific commit SHA to use as the base for your new commit. This is particularly useful for: + +- **Avoiding duplicate commits** after rebases +- **Simulating force pushes** without actually force pushing +- **Maintaining clean commit history** in PRs + +### Usage Examples + +**Basic base commit usage:** +```bash +gh commit -B main -m "fix: update configs" -b a1b2c3d4e5f6789012345678901234567890abcd file.txt +``` + +**With fast-forward (simulates force push):** +```bash +gh commit -B main -m "fix: update configs" -b a1b2c3d4e5f6789012345678901234567890abcd -f file.txt +``` + +### How It Works + +- **`--base-commit` only**: Creates a new commit on top of the specified commit, but doesn't modify the branch pointer +- **`--base-commit` + `--allow-fast-forward`**: Fast-forwards the branch to the specified commit, then creates the new commit on top + +This effectively simulates a force push by allowing you to "rewrite history" from a specific point, preventing the "Update is not a fast forward" error. + +--- + ## 📂 Project Structure - `cmd/` diff --git a/cmd/args.go b/cmd/args.go index 21b16f8..e720627 100644 --- a/cmd/args.go +++ b/cmd/args.go @@ -3,15 +3,16 @@ package cmd import ( "errors" "fmt" + "log" + "os" + "strings" + "text/tabwriter" + "github.com/cli/go-gh" "github.com/fatih/color" "github.com/google/uuid" "github.com/olekukonko/tablewriter" "github.com/spf13/cobra" - "log" - "os" - "strings" - "text/tabwriter" ) type Flag struct { diff --git a/cmd/execute.go b/cmd/execute.go index 5de408a..d2156dd 100644 --- a/cmd/execute.go +++ b/cmd/execute.go @@ -2,16 +2,17 @@ package cmd import ( "fmt" + "os" + "text/tabwriter" + "github.com/cli/go-gh/pkg/api" "github.com/cli/go-gh/pkg/repository" "github.com/fatih/color" "github.com/spf13/cobra" - "os" - "text/tabwriter" ) // VERSION number: changed in CI -const VERSION = "v0.2.4" +const VERSION = "v0.2.5" var rootPath string var repo repository.Repository diff --git a/cmd/gh.go b/cmd/gh.go index 14214d2..d42baae 100644 --- a/cmd/gh.go +++ b/cmd/gh.go @@ -6,12 +6,13 @@ import ( "encoding/json" "errors" "fmt" - "github.com/cli/go-gh" - "github.com/cli/go-gh/pkg/api" - "github.com/fatih/color" "net/http" "os" "strconv" + + "github.com/cli/go-gh" + "github.com/cli/go-gh/pkg/api" + "github.com/fatih/color" ) func ValidateGitRemote() (*RepoSettings, error) { diff --git a/feature-file.txt b/feature-file.txt new file mode 100644 index 0000000..c227b30 --- /dev/null +++ b/feature-file.txt @@ -0,0 +1 @@ +Feature content diff --git a/test-file.txt b/test-file.txt new file mode 100644 index 0000000..8430408 --- /dev/null +++ b/test-file.txt @@ -0,0 +1 @@ +Initial content