@arthony/keybook 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/seed/git.yaml +272 -0
package/package.json
CHANGED
package/seed/git.yaml
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# Curated git CLI essentials — branches, commits, history rewriting, recovery.
|
|
2
|
+
# Almost every entry has a `command` (Enter copies it to the clipboard); recipes
|
|
3
|
+
# use `steps` and place the canonical command in `command` so paste-and-tweak
|
|
4
|
+
# still works.
|
|
5
|
+
app: Git
|
|
6
|
+
entries:
|
|
7
|
+
# ---- Branches ----
|
|
8
|
+
- action: Create and switch to a new branch
|
|
9
|
+
command: git switch -c <name>
|
|
10
|
+
notes: Legacy synonym is `git checkout -b <name>`.
|
|
11
|
+
tags: [branch, create, checkout, new]
|
|
12
|
+
|
|
13
|
+
- action: Switch to an existing branch
|
|
14
|
+
command: git switch <name>
|
|
15
|
+
notes: Legacy synonym is `git checkout <name>`.
|
|
16
|
+
tags: [branch, checkout, switch]
|
|
17
|
+
|
|
18
|
+
- action: Delete a local branch
|
|
19
|
+
command: git branch -d <name>
|
|
20
|
+
notes: Use -D (capital) to force-delete a branch with unmerged commits.
|
|
21
|
+
tags: [branch, delete, remove]
|
|
22
|
+
|
|
23
|
+
- action: Delete a remote branch
|
|
24
|
+
command: git push origin --delete <name>
|
|
25
|
+
tags: [branch, delete, remote, push]
|
|
26
|
+
|
|
27
|
+
- action: Rename the current branch
|
|
28
|
+
command: git branch -m <new-name>
|
|
29
|
+
tags: [branch, rename, move]
|
|
30
|
+
|
|
31
|
+
# ---- Commits & undo ----
|
|
32
|
+
- action: Amend the last commit (edit message and/or fold in staged changes)
|
|
33
|
+
command: git commit --amend
|
|
34
|
+
notes: Rewrites the most recent commit. Force-push needed if already pushed.
|
|
35
|
+
tags: [amend, commit, edit, message]
|
|
36
|
+
|
|
37
|
+
- action: Amend the last commit without changing its message
|
|
38
|
+
command: git commit --amend --no-edit
|
|
39
|
+
notes: Quietly folds new staged changes into the most recent commit.
|
|
40
|
+
tags: [amend, fixup, no-edit, commit]
|
|
41
|
+
|
|
42
|
+
- action: Unstage a file but keep the working-copy change
|
|
43
|
+
command: git restore --staged <file>
|
|
44
|
+
notes: Legacy synonym is `git reset HEAD <file>`.
|
|
45
|
+
tags: [unstage, reset, restore]
|
|
46
|
+
|
|
47
|
+
- action: Discard local changes to a file (destructive)
|
|
48
|
+
command: git restore <file>
|
|
49
|
+
notes: The file's uncommitted edits are gone. Legacy `git checkout -- <file>`.
|
|
50
|
+
tags: [discard, undo, restore, dangerous]
|
|
51
|
+
|
|
52
|
+
- action: Undo the last commit but keep its changes staged
|
|
53
|
+
command: git reset --soft HEAD~1
|
|
54
|
+
tags: [undo, reset, soft, uncommit]
|
|
55
|
+
|
|
56
|
+
- action: Hard-reset to a specific commit (destructive)
|
|
57
|
+
command: git reset --hard <ref>
|
|
58
|
+
notes: >-
|
|
59
|
+
Wipes working tree AND index. If you regret it, find the pre-reset HEAD in
|
|
60
|
+
`git reflog` and `git reset --hard <sha>` to recover (within 90 days).
|
|
61
|
+
tags: [reset, hard, dangerous, undo]
|
|
62
|
+
|
|
63
|
+
- action: Set the per-repo author email (useful for work/personal split)
|
|
64
|
+
command: git config user.email "<address>"
|
|
65
|
+
notes: Drop --global to scope to the current repo only. Pair with `git config user.name`.
|
|
66
|
+
tags: [config, email, identity, author]
|
|
67
|
+
|
|
68
|
+
# ---- Stash ----
|
|
69
|
+
- action: Stash all changes including untracked files
|
|
70
|
+
command: git stash -u
|
|
71
|
+
notes: -u (--include-untracked) saves new files too; without it, untracked stays put.
|
|
72
|
+
tags: [stash, save, wip, untracked]
|
|
73
|
+
|
|
74
|
+
- action: Stash with a message
|
|
75
|
+
command: git stash push -m "<message>"
|
|
76
|
+
tags: [stash, message, save]
|
|
77
|
+
|
|
78
|
+
- action: List all stashes
|
|
79
|
+
command: git stash list
|
|
80
|
+
tags: [stash, list]
|
|
81
|
+
|
|
82
|
+
- action: Apply and drop the most recent stash
|
|
83
|
+
command: git stash pop
|
|
84
|
+
notes: Use `git stash apply` to keep the stash on the list after applying.
|
|
85
|
+
tags: [stash, pop, apply, restore]
|
|
86
|
+
|
|
87
|
+
# ---- Log & inspect ----
|
|
88
|
+
- action: Pretty one-line log with a branch graph
|
|
89
|
+
command: git log --oneline --graph --all --decorate
|
|
90
|
+
notes: Add `--first-parent` to flatten merge-heavy branches.
|
|
91
|
+
tags: [log, history, graph, decorate]
|
|
92
|
+
|
|
93
|
+
- action: Show what changed in the last commit
|
|
94
|
+
command: git show
|
|
95
|
+
notes: Append a sha or ref (e.g. `git show HEAD~2`) to inspect any commit.
|
|
96
|
+
tags: [show, diff, last, commit]
|
|
97
|
+
|
|
98
|
+
- action: Diff staged vs unstaged changes
|
|
99
|
+
steps:
|
|
100
|
+
- "`git diff` shows unstaged changes (working tree vs index)"
|
|
101
|
+
- "`git diff --staged` shows staged changes (index vs HEAD); --cached is the same"
|
|
102
|
+
notes: Add `-- <path>` to either to scope to a file.
|
|
103
|
+
tags: [diff, staged, cached, unstaged]
|
|
104
|
+
|
|
105
|
+
- action: Blame a file showing commit and author per line
|
|
106
|
+
command: git blame <file>
|
|
107
|
+
notes: Add `-L 10,20` to limit to a line range; `-w` ignores whitespace-only changes.
|
|
108
|
+
tags: [blame, who, author, line]
|
|
109
|
+
|
|
110
|
+
- action: Find which commit introduced a string (pickaxe search)
|
|
111
|
+
command: git log -S "<text>" --source --all
|
|
112
|
+
notes: -S finds commits that change the literal-string count; use -G for a regex.
|
|
113
|
+
tags: [search, pickaxe, history, find, who]
|
|
114
|
+
|
|
115
|
+
# ---- Remote ----
|
|
116
|
+
- action: Force-push safely (refuses to overwrite remote work you haven't seen)
|
|
117
|
+
command: git push --force-with-lease
|
|
118
|
+
notes: >-
|
|
119
|
+
Prefer this over plain --force. It errors if the remote moved since your
|
|
120
|
+
last fetch, preventing accidental overwrites of teammates' commits.
|
|
121
|
+
tags: [push, force, force-with-lease, safe]
|
|
122
|
+
|
|
123
|
+
- action: Fetch all remotes and prune deleted upstream branches
|
|
124
|
+
command: git fetch --all --prune
|
|
125
|
+
tags: [fetch, prune, cleanup, remote]
|
|
126
|
+
|
|
127
|
+
- action: Pull with rebase (replay your local commits on top of upstream)
|
|
128
|
+
command: git pull --rebase
|
|
129
|
+
notes: Set `git config --global pull.rebase true` to make this the default.
|
|
130
|
+
tags: [pull, rebase, update]
|
|
131
|
+
|
|
132
|
+
- action: Push the current branch and set its upstream
|
|
133
|
+
command: git push -u origin HEAD
|
|
134
|
+
notes: After this, plain `git push` / `git pull` work without arguments on this branch.
|
|
135
|
+
tags: [push, upstream, set-upstream]
|
|
136
|
+
|
|
137
|
+
# ---- Rebase, merge, conflicts ----
|
|
138
|
+
- action: Interactive rebase the last N commits
|
|
139
|
+
command: git rebase -i HEAD~<N>
|
|
140
|
+
notes: >-
|
|
141
|
+
In the editor: change `pick` to `reword` (edit message), `squash` (fold into
|
|
142
|
+
previous, keep both messages), `fixup` (squash and drop message), `drop`
|
|
143
|
+
(remove the commit), or reorder lines. Resume with `git rebase --continue`.
|
|
144
|
+
tags: [rebase, interactive, squash, reword, fixup]
|
|
145
|
+
|
|
146
|
+
- action: Resolve a merge conflict
|
|
147
|
+
command: git merge --continue
|
|
148
|
+
steps:
|
|
149
|
+
- "`git status` lists the conflicting files (marked \"both modified\")"
|
|
150
|
+
- Open each file; replace the `<<<<<<<` / `=======` / `>>>>>>>` blocks with the desired content
|
|
151
|
+
- "`git add <files>` to mark each resolved file"
|
|
152
|
+
- "`git commit` (or `git merge --continue`) to finish the merge"
|
|
153
|
+
notes: >-
|
|
154
|
+
Bail out with `git merge --abort` (restores pre-merge state). During a
|
|
155
|
+
rebase, use `git rebase --continue` / `--abort` instead.
|
|
156
|
+
tags: [merge, conflict, resolve, fix]
|
|
157
|
+
|
|
158
|
+
- action: Take "ours" or "theirs" wholesale during a conflict
|
|
159
|
+
steps:
|
|
160
|
+
- "`git checkout --ours <file>` keeps the version from your current branch"
|
|
161
|
+
- "`git checkout --theirs <file>` takes the version from the other branch"
|
|
162
|
+
- "`git add <file>` then `git commit` (or `--continue`)"
|
|
163
|
+
notes: >-
|
|
164
|
+
During a rebase, ours/theirs are FLIPPED — rebase replays your commits onto
|
|
165
|
+
theirs, so "ours" refers to the branch you're rebasing onto.
|
|
166
|
+
tags: [conflict, ours, theirs, merge, rebase]
|
|
167
|
+
|
|
168
|
+
- action: Abort a merge in progress
|
|
169
|
+
command: git merge --abort
|
|
170
|
+
notes: Use `git rebase --abort` if you're mid-rebase instead.
|
|
171
|
+
tags: [merge, abort, cancel]
|
|
172
|
+
|
|
173
|
+
- action: Cherry-pick a commit onto the current branch
|
|
174
|
+
command: git cherry-pick <sha>
|
|
175
|
+
notes: Use a range like `<a>^..<b>` to pick a series in order.
|
|
176
|
+
tags: [cherry-pick, copy, apply]
|
|
177
|
+
|
|
178
|
+
- action: Safely undo a commit by adding an inverse commit
|
|
179
|
+
command: git revert <sha>
|
|
180
|
+
notes: Non-destructive — creates a new commit that undoes the target. Safe on shared branches.
|
|
181
|
+
tags: [revert, undo, safe, inverse]
|
|
182
|
+
|
|
183
|
+
# ---- History rewriting ----
|
|
184
|
+
- action: Remove a co-author trailer from every commit (cleanup after Claude etc.)
|
|
185
|
+
command: |
|
|
186
|
+
git filter-repo --message-callback '
|
|
187
|
+
import re
|
|
188
|
+
return re.sub(rb"^Co-authored-by:.*\n?", b"", message, flags=re.MULTILINE)
|
|
189
|
+
'
|
|
190
|
+
steps:
|
|
191
|
+
- "Install once: `brew install git-filter-repo`"
|
|
192
|
+
- Ensure the working tree is clean (no staged or unstaged changes)
|
|
193
|
+
- Run the filter-repo command (Enter copies it from the preview)
|
|
194
|
+
- "Re-add the remote (filter-repo strips it for safety): `git remote add origin <url>`"
|
|
195
|
+
- "Force-push: `git push --force-with-lease --all && git push --force-with-lease --tags`"
|
|
196
|
+
notes: >-
|
|
197
|
+
Destructive — every commit SHA changes. Coordinate with anyone who has
|
|
198
|
+
cloned the repo so they re-clone or hard-reset their local copy.
|
|
199
|
+
tags: [filter-repo, rewrite, co-author, cleanup, claude, history]
|
|
200
|
+
|
|
201
|
+
- action: Squash the last N commits into one
|
|
202
|
+
command: git rebase -i HEAD~<N>
|
|
203
|
+
steps:
|
|
204
|
+
- "`git rebase -i HEAD~<N>`"
|
|
205
|
+
- In the editor, change `pick` to `squash` on every line EXCEPT the first
|
|
206
|
+
- Save and quit; the next editor lets you craft the combined commit message
|
|
207
|
+
notes: Use `fixup` instead of `squash` to keep only the first commit's message.
|
|
208
|
+
tags: [squash, rebase, combine, history]
|
|
209
|
+
|
|
210
|
+
- action: Edit the message of an old commit
|
|
211
|
+
steps:
|
|
212
|
+
- "`git rebase -i HEAD~<N>` where N is far enough back to include the target"
|
|
213
|
+
- "Change `pick` to `reword` on the target line; save and quit"
|
|
214
|
+
- Edit the message in the next editor; save and quit
|
|
215
|
+
- "`git rebase --continue` if anything else needs attention"
|
|
216
|
+
command: git rebase -i HEAD~<N>
|
|
217
|
+
notes: SHAs from that commit onward change; force-push needed if already pushed.
|
|
218
|
+
tags: [rebase, reword, message, history]
|
|
219
|
+
|
|
220
|
+
- action: Drop a commit from history
|
|
221
|
+
steps:
|
|
222
|
+
- "`git rebase -i HEAD~<N>`"
|
|
223
|
+
- Delete the line (or change `pick` to `drop`) for the commit to remove
|
|
224
|
+
- Save and quit; resolve any conflicts with `--continue`
|
|
225
|
+
command: git rebase -i HEAD~<N>
|
|
226
|
+
notes: Prefer `git revert <sha>` if the commit is already shared with others.
|
|
227
|
+
tags: [rebase, drop, remove, history]
|
|
228
|
+
|
|
229
|
+
# ---- Recovery & tags ----
|
|
230
|
+
- action: View the reflog to find lost commits
|
|
231
|
+
command: git reflog
|
|
232
|
+
notes: >-
|
|
233
|
+
Every HEAD-changing operation leaves an entry. Recover with `git reset
|
|
234
|
+
--hard <sha>` or `git checkout <sha>`. Entries expire after 90 days by default.
|
|
235
|
+
tags: [reflog, recover, lost, history, undo]
|
|
236
|
+
|
|
237
|
+
- action: Recover after a bad reset or rebase
|
|
238
|
+
steps:
|
|
239
|
+
- "`git reflog` to find the entry just BEFORE the bad operation"
|
|
240
|
+
- "Note the sha or HEAD@{N} reference"
|
|
241
|
+
- "`git reset --hard HEAD@{N}` (or `git reset --hard <sha>`)"
|
|
242
|
+
command: git reflog
|
|
243
|
+
notes: Reflog entries expire after 90 days by default — act soon.
|
|
244
|
+
tags: [reflog, recover, undo, mistake, rescue]
|
|
245
|
+
|
|
246
|
+
- action: Find the commit that broke things (git bisect)
|
|
247
|
+
steps:
|
|
248
|
+
- "`git bisect start`"
|
|
249
|
+
- "`git bisect bad` to mark HEAD as bad"
|
|
250
|
+
- "`git bisect good <ref>` to mark a known-good past commit or tag"
|
|
251
|
+
- Test at each step; mark with `git bisect good` or `git bisect bad`
|
|
252
|
+
- "`git bisect reset` to return to where you started"
|
|
253
|
+
command: git bisect start
|
|
254
|
+
notes: Automate with `git bisect run <script>` for hands-off bisection.
|
|
255
|
+
tags: [bisect, regression, find, debug, broke]
|
|
256
|
+
|
|
257
|
+
- action: Create an annotated tag
|
|
258
|
+
command: git tag -a v<version> -m "<message>"
|
|
259
|
+
notes: Annotated tags carry author + date + message; prefer them over lightweight `git tag <name>`.
|
|
260
|
+
tags: [tag, release, annotated, version]
|
|
261
|
+
|
|
262
|
+
- action: Push a specific tag to the remote
|
|
263
|
+
command: git push origin v<version>
|
|
264
|
+
notes: Use `git push --tags` to push all local tags at once.
|
|
265
|
+
tags: [tag, push, release, remote]
|
|
266
|
+
|
|
267
|
+
- action: Delete a tag locally and on the remote
|
|
268
|
+
steps:
|
|
269
|
+
- "`git tag -d v<version>` removes it locally"
|
|
270
|
+
- "`git push origin --delete v<version>` removes it from the remote"
|
|
271
|
+
command: git push origin --delete v<version>
|
|
272
|
+
tags: [tag, delete, remove, remote]
|