You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -28,15 +31,21 @@ _git-draft_ is a git-centric way to edit code using AI.
28
31
29
32
=== How it works
30
33
31
-
When you create a new draft with `git draft -C $name`, a new branch called `$branch/drafts/$name-$hash` is created (`$hash` is a random suffix used to guarantee uniqueness of branch names) and checked out.
32
-
Additionally, any uncommitted changes are automatically committed (`draft! sync`).
33
34
34
-
Once the draft is created, we can use AI to edit our code using `git draft -E`.
35
-
It expects the prompt as standard input, for example `echo "Add a test for compute_offset in chart.py" | git draft -E`.
36
-
The prompt will automatically get augmented with information about the files in the repository, and give the AI access to tools for reading and writing files.
37
-
Once the response has been received and changes, applied a commit is created (`draft! prompt: a short summary of the change`).
35
+
The workhorse command is `git draft --generate` which leverages AI to edit our code.
36
+
A prompt can be specified as standard input, for example `echo "Add a test for compute_offset in chart.py" | git draft --generate`.
37
+
If no prompt is specified and stdin is a TTY, `$EDITOR` will be opened to enter the prompt.
38
+
39
+
If not on a draft branch, a new draft branch called `drafts/$parent/$hash` will be created (`$hash` is a random suffix used to guarantee uniqueness of branch names) and checked out.
40
+
By default any unstaged changes are then automatically added and committed (`draft! sync`).
41
+
This behavior can be disabled by passing in `--stash`, which will instead add them to the stash.
42
+
Staged changes are always committed.
43
+
44
+
The prompt automatically gets augmented with information about the files in the repository, and give the AI access to tools for reading and writing files.
45
+
Once the response has been received and changes applied, a commit is created (`draft! prompt: a short summary of the change`).
38
46
39
-
The prompt step can be repeated as many times as needed. Once you are satisfied with the changes, run `git draft -A` to apply them.
47
+
The `--generate` step can be repeated as many times as needed.
48
+
Once you are satisfied with the changes, run `git draft --finalize` to apply them.
40
49
This will check out the branch used when creating the draft, adding the final state of the draft to the worktree.
41
50
Note that you can come back to an existing draft anytime (by checking its branch out), but you will not be able to apply it if its origin branch has moved since the draft was created.
0 commit comments