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
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Expand All @@ -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/`
Expand Down
9 changes: 5 additions & 4 deletions cmd/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions cmd/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions cmd/gh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions feature-file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Feature content
1 change: 1 addition & 0 deletions test-file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Initial content