kollabor 0.4.9__py3-none-any.whl → 0.4.15__py3-none-any.whl
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.
- agents/__init__.py +2 -0
- agents/coder/__init__.py +0 -0
- agents/coder/agent.json +4 -0
- agents/coder/api-integration.md +2150 -0
- agents/coder/cli-pretty.md +765 -0
- agents/coder/code-review.md +1092 -0
- agents/coder/database-design.md +1525 -0
- agents/coder/debugging.md +1102 -0
- agents/coder/dependency-management.md +1397 -0
- agents/coder/git-workflow.md +1099 -0
- agents/coder/refactoring.md +1454 -0
- agents/coder/security-hardening.md +1732 -0
- agents/coder/system_prompt.md +1448 -0
- agents/coder/tdd.md +1367 -0
- agents/creative-writer/__init__.py +0 -0
- agents/creative-writer/agent.json +4 -0
- agents/creative-writer/character-development.md +1852 -0
- agents/creative-writer/dialogue-craft.md +1122 -0
- agents/creative-writer/plot-structure.md +1073 -0
- agents/creative-writer/revision-editing.md +1484 -0
- agents/creative-writer/system_prompt.md +690 -0
- agents/creative-writer/worldbuilding.md +2049 -0
- agents/data-analyst/__init__.py +30 -0
- agents/data-analyst/agent.json +4 -0
- agents/data-analyst/data-visualization.md +992 -0
- agents/data-analyst/exploratory-data-analysis.md +1110 -0
- agents/data-analyst/pandas-data-manipulation.md +1081 -0
- agents/data-analyst/sql-query-optimization.md +881 -0
- agents/data-analyst/statistical-analysis.md +1118 -0
- agents/data-analyst/system_prompt.md +928 -0
- agents/default/__init__.py +0 -0
- agents/default/agent.json +4 -0
- agents/default/dead-code.md +794 -0
- agents/default/explore-agent-system.md +585 -0
- agents/default/system_prompt.md +1448 -0
- agents/kollabor/__init__.py +0 -0
- agents/kollabor/analyze-plugin-lifecycle.md +175 -0
- agents/kollabor/analyze-terminal-rendering.md +388 -0
- agents/kollabor/code-review.md +1092 -0
- agents/kollabor/debug-mcp-integration.md +521 -0
- agents/kollabor/debug-plugin-hooks.md +547 -0
- agents/kollabor/debugging.md +1102 -0
- agents/kollabor/dependency-management.md +1397 -0
- agents/kollabor/git-workflow.md +1099 -0
- agents/kollabor/inspect-llm-conversation.md +148 -0
- agents/kollabor/monitor-event-bus.md +558 -0
- agents/kollabor/profile-performance.md +576 -0
- agents/kollabor/refactoring.md +1454 -0
- agents/kollabor/system_prompt copy.md +1448 -0
- agents/kollabor/system_prompt.md +757 -0
- agents/kollabor/trace-command-execution.md +178 -0
- agents/kollabor/validate-config.md +879 -0
- agents/research/__init__.py +0 -0
- agents/research/agent.json +4 -0
- agents/research/architecture-mapping.md +1099 -0
- agents/research/codebase-analysis.md +1077 -0
- agents/research/dependency-audit.md +1027 -0
- agents/research/performance-profiling.md +1047 -0
- agents/research/security-review.md +1359 -0
- agents/research/system_prompt.md +492 -0
- agents/technical-writer/__init__.py +0 -0
- agents/technical-writer/agent.json +4 -0
- agents/technical-writer/api-documentation.md +2328 -0
- agents/technical-writer/changelog-management.md +1181 -0
- agents/technical-writer/readme-writing.md +1360 -0
- agents/technical-writer/style-guide.md +1410 -0
- agents/technical-writer/system_prompt.md +653 -0
- agents/technical-writer/tutorial-creation.md +1448 -0
- core/__init__.py +0 -2
- core/application.py +343 -88
- core/cli.py +229 -10
- core/commands/menu_renderer.py +463 -59
- core/commands/registry.py +14 -9
- core/commands/system_commands.py +2461 -14
- core/config/loader.py +151 -37
- core/config/service.py +18 -6
- core/events/bus.py +29 -9
- core/events/executor.py +205 -75
- core/events/models.py +27 -8
- core/fullscreen/command_integration.py +20 -24
- core/fullscreen/components/__init__.py +10 -1
- core/fullscreen/components/matrix_components.py +1 -2
- core/fullscreen/components/space_shooter_components.py +654 -0
- core/fullscreen/plugin.py +5 -0
- core/fullscreen/renderer.py +52 -13
- core/fullscreen/session.py +52 -15
- core/io/__init__.py +29 -5
- core/io/buffer_manager.py +6 -1
- core/io/config_status_view.py +7 -29
- core/io/core_status_views.py +267 -347
- core/io/input/__init__.py +25 -0
- core/io/input/command_mode_handler.py +711 -0
- core/io/input/display_controller.py +128 -0
- core/io/input/hook_registrar.py +286 -0
- core/io/input/input_loop_manager.py +421 -0
- core/io/input/key_press_handler.py +502 -0
- core/io/input/modal_controller.py +1011 -0
- core/io/input/paste_processor.py +339 -0
- core/io/input/status_modal_renderer.py +184 -0
- core/io/input_errors.py +5 -1
- core/io/input_handler.py +211 -2452
- core/io/key_parser.py +7 -0
- core/io/layout.py +15 -3
- core/io/message_coordinator.py +111 -2
- core/io/message_renderer.py +129 -4
- core/io/status_renderer.py +147 -607
- core/io/terminal_renderer.py +97 -51
- core/io/terminal_state.py +21 -4
- core/io/visual_effects.py +816 -165
- core/llm/agent_manager.py +1063 -0
- core/llm/api_adapters/__init__.py +44 -0
- core/llm/api_adapters/anthropic_adapter.py +432 -0
- core/llm/api_adapters/base.py +241 -0
- core/llm/api_adapters/openai_adapter.py +326 -0
- core/llm/api_communication_service.py +167 -113
- core/llm/conversation_logger.py +322 -16
- core/llm/conversation_manager.py +556 -30
- core/llm/file_operations_executor.py +84 -32
- core/llm/llm_service.py +934 -103
- core/llm/mcp_integration.py +541 -57
- core/llm/message_display_service.py +135 -18
- core/llm/plugin_sdk.py +1 -2
- core/llm/profile_manager.py +1183 -0
- core/llm/response_parser.py +274 -56
- core/llm/response_processor.py +16 -3
- core/llm/tool_executor.py +6 -1
- core/logging/__init__.py +2 -0
- core/logging/setup.py +34 -6
- core/models/resume.py +54 -0
- core/plugins/__init__.py +4 -2
- core/plugins/base.py +127 -0
- core/plugins/collector.py +23 -161
- core/plugins/discovery.py +37 -3
- core/plugins/factory.py +6 -12
- core/plugins/registry.py +5 -17
- core/ui/config_widgets.py +128 -28
- core/ui/live_modal_renderer.py +2 -1
- core/ui/modal_actions.py +5 -0
- core/ui/modal_overlay_renderer.py +0 -60
- core/ui/modal_renderer.py +268 -7
- core/ui/modal_state_manager.py +29 -4
- core/ui/widgets/base_widget.py +7 -0
- core/updates/__init__.py +10 -0
- core/updates/version_check_service.py +348 -0
- core/updates/version_comparator.py +103 -0
- core/utils/config_utils.py +685 -526
- core/utils/plugin_utils.py +1 -1
- core/utils/session_naming.py +111 -0
- fonts/LICENSE +21 -0
- fonts/README.md +46 -0
- fonts/SymbolsNerdFont-Regular.ttf +0 -0
- fonts/SymbolsNerdFontMono-Regular.ttf +0 -0
- fonts/__init__.py +44 -0
- {kollabor-0.4.9.dist-info → kollabor-0.4.15.dist-info}/METADATA +54 -4
- kollabor-0.4.15.dist-info/RECORD +228 -0
- {kollabor-0.4.9.dist-info → kollabor-0.4.15.dist-info}/top_level.txt +2 -0
- plugins/agent_orchestrator/__init__.py +39 -0
- plugins/agent_orchestrator/activity_monitor.py +181 -0
- plugins/agent_orchestrator/file_attacher.py +77 -0
- plugins/agent_orchestrator/message_injector.py +135 -0
- plugins/agent_orchestrator/models.py +48 -0
- plugins/agent_orchestrator/orchestrator.py +403 -0
- plugins/agent_orchestrator/plugin.py +976 -0
- plugins/agent_orchestrator/xml_parser.py +191 -0
- plugins/agent_orchestrator_plugin.py +9 -0
- plugins/enhanced_input/box_styles.py +1 -0
- plugins/enhanced_input/color_engine.py +19 -4
- plugins/enhanced_input/config.py +2 -2
- plugins/enhanced_input_plugin.py +61 -11
- plugins/fullscreen/__init__.py +6 -2
- plugins/fullscreen/example_plugin.py +1035 -222
- plugins/fullscreen/setup_wizard_plugin.py +592 -0
- plugins/fullscreen/space_shooter_plugin.py +131 -0
- plugins/hook_monitoring_plugin.py +436 -78
- plugins/query_enhancer_plugin.py +66 -30
- plugins/resume_conversation_plugin.py +1494 -0
- plugins/save_conversation_plugin.py +98 -32
- plugins/system_commands_plugin.py +70 -56
- plugins/tmux_plugin.py +154 -78
- plugins/workflow_enforcement_plugin.py +94 -92
- system_prompt/default.md +952 -886
- core/io/input_mode_manager.py +0 -402
- core/io/modal_interaction_handler.py +0 -315
- core/io/raw_input_processor.py +0 -946
- core/storage/__init__.py +0 -5
- core/storage/state_manager.py +0 -84
- core/ui/widget_integration.py +0 -222
- core/utils/key_reader.py +0 -171
- kollabor-0.4.9.dist-info/RECORD +0 -128
- {kollabor-0.4.9.dist-info → kollabor-0.4.15.dist-info}/WHEEL +0 -0
- {kollabor-0.4.9.dist-info → kollabor-0.4.15.dist-info}/entry_points.txt +0 -0
- {kollabor-0.4.9.dist-info → kollabor-0.4.15.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,1099 @@
|
|
|
1
|
+
<!-- Git Workflow skill - professional version control practices -->
|
|
2
|
+
|
|
3
|
+
git workflow mode: CLEAN HISTORY, CLEAR INTENT
|
|
4
|
+
|
|
5
|
+
when this skill is active, you follow disciplined git practices.
|
|
6
|
+
this is a comprehensive guide to professional version control.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
PHASE 0: ENVIRONMENT VERIFICATION
|
|
10
|
+
|
|
11
|
+
before doing ANY git operations, verify your configuration.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
verify git is installed
|
|
15
|
+
|
|
16
|
+
<terminal>git --version</terminal>
|
|
17
|
+
|
|
18
|
+
if git not installed:
|
|
19
|
+
macOS:
|
|
20
|
+
<terminal>brew install git</terminal>
|
|
21
|
+
|
|
22
|
+
linux:
|
|
23
|
+
<terminal>sudo apt install git</terminal>
|
|
24
|
+
<terminal>sudo yum install git</terminal>
|
|
25
|
+
|
|
26
|
+
windows:
|
|
27
|
+
<terminal>winget install Git.Git</terminal>
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
verify git identity
|
|
31
|
+
|
|
32
|
+
<terminal>git config --global user.name</terminal>
|
|
33
|
+
|
|
34
|
+
<terminal>git config --global user.email</terminal>
|
|
35
|
+
|
|
36
|
+
if not configured:
|
|
37
|
+
|
|
38
|
+
<terminal>git config --global user.name "Your Name"</terminal>
|
|
39
|
+
|
|
40
|
+
<terminal>git config --global user.email "you@example.com"</terminal>
|
|
41
|
+
|
|
42
|
+
critical: use your real email.
|
|
43
|
+
your identity is part of the permanent record.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
verify default branch
|
|
47
|
+
|
|
48
|
+
<terminal>git config --global init.defaultBranch</terminal>
|
|
49
|
+
|
|
50
|
+
if not set:
|
|
51
|
+
|
|
52
|
+
<terminal>git config --global init.defaultBranch main</terminal>
|
|
53
|
+
|
|
54
|
+
modern standard: main, not master.
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
verify useful defaults
|
|
58
|
+
|
|
59
|
+
<terminal>git config --global core.autocrlf</terminal>
|
|
60
|
+
|
|
61
|
+
macOS/Linux:
|
|
62
|
+
<terminal>git config --global core.autocrlf input</terminal>
|
|
63
|
+
|
|
64
|
+
windows:
|
|
65
|
+
<terminal>git config --global core.autocrlf true</terminal>
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
enable helpful options
|
|
69
|
+
|
|
70
|
+
<terminal>git config --global core.quotePath false</terminal>
|
|
71
|
+
|
|
72
|
+
<terminal>git config --global init.defaultBranch main</terminal>
|
|
73
|
+
|
|
74
|
+
<terminal>git config --global rebase.autoStash true</terminal>
|
|
75
|
+
|
|
76
|
+
<terminal>git config --global push.autoSetupRemote true</terminal>
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
verify remote access
|
|
80
|
+
|
|
81
|
+
<terminal>git remote -v</terminal>
|
|
82
|
+
|
|
83
|
+
if no remote:
|
|
84
|
+
[warn] working without backup
|
|
85
|
+
[warn] push to remote frequently
|
|
86
|
+
|
|
87
|
+
if remote exists, verify access:
|
|
88
|
+
<terminal>git ls-remote origin</terminal>
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
verify current repository state
|
|
92
|
+
|
|
93
|
+
<terminal>git status</terminal>
|
|
94
|
+
|
|
95
|
+
<terminal>git branch --show-current</terminal>
|
|
96
|
+
|
|
97
|
+
<terminal>git log --oneline -5</terminal>
|
|
98
|
+
|
|
99
|
+
understand where you are before making changes.
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
PHASE 1: GIT FUNDAMENTALS
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
the three states
|
|
106
|
+
|
|
107
|
+
working directory -> staging area -> repository
|
|
108
|
+
|
|
109
|
+
working directory: your actual files
|
|
110
|
+
staging area: files prepared for commit
|
|
111
|
+
repository: committed history
|
|
112
|
+
|
|
113
|
+
<terminal>git status</terminal>
|
|
114
|
+
|
|
115
|
+
shows: which files are in which state
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
the basic commands
|
|
119
|
+
|
|
120
|
+
add: move file from working to staging
|
|
121
|
+
<terminal>git add filename.py</terminal>
|
|
122
|
+
|
|
123
|
+
commit: move from staging to repository
|
|
124
|
+
<terminal>git commit -m "message"</terminal>
|
|
125
|
+
|
|
126
|
+
status: see what state files are in
|
|
127
|
+
<terminal>git status</terminal>
|
|
128
|
+
|
|
129
|
+
diff: see what changed
|
|
130
|
+
<terminal>git diff</terminal> # working vs staging
|
|
131
|
+
<terminal>git diff --staged</terminal> # staging vs repository
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
reading git status
|
|
135
|
+
|
|
136
|
+
$ git status
|
|
137
|
+
On branch main
|
|
138
|
+
Your branch is up to date with 'origin/main'.
|
|
139
|
+
|
|
140
|
+
Changes not staged for commit:
|
|
141
|
+
modified: app.py
|
|
142
|
+
modified: utils.py
|
|
143
|
+
|
|
144
|
+
Untracked files:
|
|
145
|
+
new_file.py
|
|
146
|
+
|
|
147
|
+
breakdown:
|
|
148
|
+
- on branch main: current branch
|
|
149
|
+
- up to date: local matches origin
|
|
150
|
+
- modified: changed but not staged
|
|
151
|
+
- untracked: new file, not tracked
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
PHASE 2: BRANCHING STRATEGY
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
why branch
|
|
158
|
+
|
|
159
|
+
branches enable:
|
|
160
|
+
- parallel work
|
|
161
|
+
- isolation of changes
|
|
162
|
+
- safe experimentation
|
|
163
|
+
- code review before merge
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
branch naming conventions
|
|
167
|
+
|
|
168
|
+
feature work:
|
|
169
|
+
feature/add-user-authentication
|
|
170
|
+
feature/payment-processing
|
|
171
|
+
feat/shopping-cart
|
|
172
|
+
|
|
173
|
+
bug fixes:
|
|
174
|
+
bugfix/login-timeout
|
|
175
|
+
fix/memory-leak
|
|
176
|
+
hotfix/security-patch
|
|
177
|
+
|
|
178
|
+
chores:
|
|
179
|
+
refactor/user-module
|
|
180
|
+
chore/update-dependencies
|
|
181
|
+
docs/api-endpoints
|
|
182
|
+
test/add-user-tests
|
|
183
|
+
|
|
184
|
+
release:
|
|
185
|
+
release/v1.2.0
|
|
186
|
+
prepare-release/v1.0.0
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
create a branch
|
|
190
|
+
|
|
191
|
+
<terminal>git checkout -b feature/add-user-auth</terminal>
|
|
192
|
+
|
|
193
|
+
equivalent:
|
|
194
|
+
<terminal>git branch feature/add-user-auth</terminal>
|
|
195
|
+
<terminal>git checkout feature/add-user-auth</terminal>
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
list branches
|
|
199
|
+
|
|
200
|
+
<terminal>git branch</terminal>
|
|
201
|
+
|
|
202
|
+
<terminal>git branch -a</terminal> # show remote too
|
|
203
|
+
<terminal>git branch -vv</terminal> # show tracking info
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
switch branches
|
|
207
|
+
|
|
208
|
+
<terminal>git checkout main</terminal>
|
|
209
|
+
|
|
210
|
+
<terminal>git switch feature/add-user-auth</terminal>
|
|
211
|
+
|
|
212
|
+
note: git switch is newer, more intuitive
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
delete branches
|
|
216
|
+
|
|
217
|
+
local:
|
|
218
|
+
<terminal>git branch -d feature/complete</terminal>
|
|
219
|
+
|
|
220
|
+
force delete (unmerged):
|
|
221
|
+
<terminal>git branch -D feature/experimental</terminal>
|
|
222
|
+
|
|
223
|
+
remote:
|
|
224
|
+
<terminal>git push origin --delete feature/complete</terminal>
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
PHASE 3: THE COMMIT HABIT
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
what makes a good commit
|
|
231
|
+
|
|
232
|
+
[ok] small, focused change
|
|
233
|
+
[ok] complete (works, tests pass)
|
|
234
|
+
[ok] clear message explaining why
|
|
235
|
+
[x] large, sweeping changes
|
|
236
|
+
[x] broken code (WIP commits)
|
|
237
|
+
[x] vague messages ("update", "fix stuff")
|
|
238
|
+
[x] multiple unrelated changes
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
commit message format
|
|
242
|
+
|
|
243
|
+
subject line (50 chars or less):
|
|
244
|
+
- imperative mood ("add" not "added" or "adds")
|
|
245
|
+
- complete sentence
|
|
246
|
+
- no trailing period
|
|
247
|
+
|
|
248
|
+
body (optional):
|
|
249
|
+
- what and why
|
|
250
|
+
- not how
|
|
251
|
+
- wrapped at 72 chars
|
|
252
|
+
|
|
253
|
+
examples:
|
|
254
|
+
|
|
255
|
+
add user authentication with JWT tokens
|
|
256
|
+
|
|
257
|
+
implement login and registration endpoints with JWT-based
|
|
258
|
+
authentication. passwords are hashed with bcrypt.
|
|
259
|
+
|
|
260
|
+
fixes #123
|
|
261
|
+
|
|
262
|
+
refactor: extract user validation to separate module
|
|
263
|
+
|
|
264
|
+
the validation logic was duplicated across multiple controllers.
|
|
265
|
+
extracting to a shared module reduces duplication and makes
|
|
266
|
+
testing easier.
|
|
267
|
+
|
|
268
|
+
fix: prevent null pointer in user lookup
|
|
269
|
+
|
|
270
|
+
when a user id doesn't exist, the lookup was returning None
|
|
271
|
+
without handling, causing a null pointer error. added explicit
|
|
272
|
+
check and raise 404 instead.
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
commit often
|
|
276
|
+
|
|
277
|
+
after each logical unit:
|
|
278
|
+
- one function extracted
|
|
279
|
+
- one test written
|
|
280
|
+
- one bug fixed
|
|
281
|
+
|
|
282
|
+
benefits:
|
|
283
|
+
- easier to revert if needed
|
|
284
|
+
- clearer history
|
|
285
|
+
- smaller review chunks
|
|
286
|
+
|
|
287
|
+
anti-pattern:
|
|
288
|
+
[x] one giant commit at end of day
|
|
289
|
+
[x] "work in progress" commits that break tests
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
amend commits
|
|
293
|
+
|
|
294
|
+
only for most recent commit:
|
|
295
|
+
<terminal>git commit --amend</terminal>
|
|
296
|
+
|
|
297
|
+
only for trivial fixes (typos, forgot to add file)
|
|
298
|
+
never amend pushed commits (rewrites history)
|
|
299
|
+
|
|
300
|
+
add file to previous commit:
|
|
301
|
+
<terminal>git add forgotten_file.py</terminal>
|
|
302
|
+
<terminal>git commit --amend --no-edit</terminal>
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
PHASE 4: STAGING AND COMMITTING
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
interactive staging
|
|
309
|
+
|
|
310
|
+
stage parts of a file:
|
|
311
|
+
<terminal>git add -p filename.py</terminal>
|
|
312
|
+
|
|
313
|
+
prompts for each hunk:
|
|
314
|
+
- y: stage this hunk
|
|
315
|
+
- n: don't stage this hunk
|
|
316
|
+
- s: split into smaller hunks
|
|
317
|
+
- q: quit
|
|
318
|
+
|
|
319
|
+
useful when:
|
|
320
|
+
- file has multiple unrelated changes
|
|
321
|
+
- want atomic commits
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
stage by file
|
|
325
|
+
|
|
326
|
+
stage specific files:
|
|
327
|
+
<terminal>git add app.py utils.py</terminal>
|
|
328
|
+
|
|
329
|
+
stage all changes:
|
|
330
|
+
<terminal>git add .</terminal>
|
|
331
|
+
|
|
332
|
+
careful: stages everything
|
|
333
|
+
review first with:
|
|
334
|
+
<terminal>git status</terminal>
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
unstage files
|
|
338
|
+
|
|
339
|
+
<terminal>git restore --staged filename.py</terminal>
|
|
340
|
+
|
|
341
|
+
or:
|
|
342
|
+
<terminal>git reset HEAD filename.py</terminal>
|
|
343
|
+
|
|
344
|
+
moves from staging back to working directory
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
discard working changes
|
|
348
|
+
|
|
349
|
+
<terminal>git restore filename.py</terminal>
|
|
350
|
+
|
|
351
|
+
or:
|
|
352
|
+
<terminal>git checkout -- filename.py</terminal>
|
|
353
|
+
|
|
354
|
+
warning: destroys changes
|
|
355
|
+
be certain you don't need them
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
PHASE 5: MERGE VS REBASE
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
when to merge
|
|
362
|
+
|
|
363
|
+
use merge when:
|
|
364
|
+
- preserving complete history
|
|
365
|
+
- working on shared branch
|
|
366
|
+
- want explicit merge commit
|
|
367
|
+
|
|
368
|
+
<terminal>git checkout main</terminal>
|
|
369
|
+
<terminal>git merge feature/new-auth</terminal>
|
|
370
|
+
|
|
371
|
+
creates merge commit combining histories.
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
when to rebase
|
|
375
|
+
|
|
376
|
+
use rebase when:
|
|
377
|
+
- cleaning up local branch before push
|
|
378
|
+
- linear history preferred
|
|
379
|
+
- integrating upstream changes
|
|
380
|
+
|
|
381
|
+
<terminal>git checkout feature/new-auth</terminal>
|
|
382
|
+
<terminal>git rebase main</terminal>
|
|
383
|
+
|
|
384
|
+
reapplies your commits on top of main.
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
golden rules
|
|
388
|
+
|
|
389
|
+
[1] never rebase pushed commits
|
|
390
|
+
rebase rewrites history
|
|
391
|
+
others may have based work on those commits
|
|
392
|
+
rebase = trouble for collaborators
|
|
393
|
+
|
|
394
|
+
[2] never rebase shared branches
|
|
395
|
+
main, develop, release branches
|
|
396
|
+
only rebase your local feature branches
|
|
397
|
+
|
|
398
|
+
[3] force push with caution
|
|
399
|
+
only after rebase
|
|
400
|
+
only to your own branches
|
|
401
|
+
<terminal>git push --force-with-lease</terminal>
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
PHASE 6: HANDLING MERGE CONFLICTS
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
conflict markers
|
|
408
|
+
|
|
409
|
+
when git can't auto-merge:
|
|
410
|
+
|
|
411
|
+
<<<<<<< HEAD
|
|
412
|
+
current branch content
|
|
413
|
+
=======
|
|
414
|
+
incoming branch content
|
|
415
|
+
>>>>>>> feature-branch
|
|
416
|
+
|
|
417
|
+
you decide which to keep, or combine both.
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
resolution process
|
|
421
|
+
|
|
422
|
+
[1] identify conflict
|
|
423
|
+
<terminal>git status</terminal>
|
|
424
|
+
|
|
425
|
+
shows "both modified" files
|
|
426
|
+
|
|
427
|
+
[2] open file in editor
|
|
428
|
+
find conflict markers
|
|
429
|
+
understand what each side does
|
|
430
|
+
|
|
431
|
+
[3] resolve conflict
|
|
432
|
+
choose:
|
|
433
|
+
- keep HEAD (current)
|
|
434
|
+
- keep incoming
|
|
435
|
+
- combine both
|
|
436
|
+
- write new solution
|
|
437
|
+
|
|
438
|
+
[4] remove markers
|
|
439
|
+
delete <<<<<<<, =======, >>>>>>>
|
|
440
|
+
|
|
441
|
+
[5] stage resolution
|
|
442
|
+
<terminal>git add resolved_file.py</terminal>
|
|
443
|
+
|
|
444
|
+
[6] complete merge/rebase
|
|
445
|
+
<terminal>git commit</terminal> # for merge
|
|
446
|
+
<terminal>git rebase --continue</terminal> # for rebase
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
conflict resolution tools
|
|
450
|
+
|
|
451
|
+
use merge tool:
|
|
452
|
+
<terminal>git mergetool</terminal>
|
|
453
|
+
|
|
454
|
+
configure:
|
|
455
|
+
<terminal>git config --global merge.tool vscode</terminal>
|
|
456
|
+
<terminal>git config --global mergetool.vscode.cmd 'code --wait $MERGED'</terminal>
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
abort on trouble
|
|
460
|
+
|
|
461
|
+
abort merge:
|
|
462
|
+
<terminal>git merge --abort</terminal>
|
|
463
|
+
|
|
464
|
+
abort rebase:
|
|
465
|
+
<terminal>git rebase --abort</terminal>
|
|
466
|
+
|
|
467
|
+
returns to state before operation.
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
PHASE 7: SYNCING WITH REMOTE
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
fetch vs pull
|
|
474
|
+
|
|
475
|
+
fetch: get remote changes, don't merge
|
|
476
|
+
<terminal>git fetch origin</terminal>
|
|
477
|
+
|
|
478
|
+
safe, lets you review before integrating
|
|
479
|
+
|
|
480
|
+
pull: fetch and merge in one step
|
|
481
|
+
<terminal>git pull</terminal>
|
|
482
|
+
|
|
483
|
+
convenient but creates merge commit
|
|
484
|
+
|
|
485
|
+
pull with rebase:
|
|
486
|
+
<terminal>git pull --rebase</terminal>
|
|
487
|
+
|
|
488
|
+
cleaner history, reapplies your work on top
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
push branches
|
|
492
|
+
|
|
493
|
+
first push (set upstream):
|
|
494
|
+
<terminal>git push -u origin feature/new-auth</terminal>
|
|
495
|
+
|
|
496
|
+
subsequent pushes:
|
|
497
|
+
<terminal>git push</terminal>
|
|
498
|
+
|
|
499
|
+
with autoSetupRemote configured:
|
|
500
|
+
<terminal>git push</terminal> # sets upstream automatically
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
update local branch
|
|
504
|
+
|
|
505
|
+
when remote has updates:
|
|
506
|
+
|
|
507
|
+
<terminal>git fetch origin</terminal>
|
|
508
|
+
<terminal>git rebase origin/main</terminal>
|
|
509
|
+
|
|
510
|
+
or:
|
|
511
|
+
<terminal>git pull --rebase</terminal>
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
before starting work
|
|
515
|
+
|
|
516
|
+
always start from latest:
|
|
517
|
+
<terminal>git checkout main</terminal>
|
|
518
|
+
<terminal>git pull</terminal>
|
|
519
|
+
<terminal>git checkout -b feature/new-work</terminal>
|
|
520
|
+
|
|
521
|
+
prevents merge conflicts later
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
PHASE 8: INSPECTING HISTORY
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
view commits
|
|
528
|
+
|
|
529
|
+
recent commits:
|
|
530
|
+
<terminal>git log</terminal>
|
|
531
|
+
|
|
532
|
+
one line per commit:
|
|
533
|
+
<terminal>git log --oneline</terminal>
|
|
534
|
+
|
|
535
|
+
with graph:
|
|
536
|
+
<terminal>git log --oneline --graph --all</terminal>
|
|
537
|
+
|
|
538
|
+
pretty format:
|
|
539
|
+
<terminal>git log --pretty=format:"%h %ad | %s" --date=short</terminal>
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
view specific commit
|
|
543
|
+
|
|
544
|
+
show commit details:
|
|
545
|
+
<terminal>git show abc123</terminal>
|
|
546
|
+
|
|
547
|
+
show file at commit:
|
|
548
|
+
<terminal>git show abc123:path/to/file.py</terminal>
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
view changes
|
|
552
|
+
|
|
553
|
+
diff between commits:
|
|
554
|
+
<terminal>git diff abc123 def456</terminal>
|
|
555
|
+
|
|
556
|
+
diff between branches:
|
|
557
|
+
<terminal>git diff main feature</terminal>
|
|
558
|
+
|
|
559
|
+
what changed in file:
|
|
560
|
+
<terminal>git log -p filename.py</terminal>
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
blame: who changed what
|
|
564
|
+
|
|
565
|
+
<terminal>git blame filename.py</terminal>
|
|
566
|
+
|
|
567
|
+
shows each line with commit and author.
|
|
568
|
+
|
|
569
|
+
specific line range:
|
|
570
|
+
<terminal>git blame -L 50,60 filename.py</terminal>
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
PHASE 9: UNDOING CHANGES
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
undo working directory changes
|
|
577
|
+
|
|
578
|
+
discard all changes:
|
|
579
|
+
<terminal>git restore .</terminal>
|
|
580
|
+
|
|
581
|
+
discard specific file:
|
|
582
|
+
<terminal>git restore filename.py</terminal>
|
|
583
|
+
|
|
584
|
+
warning: cannot be undone
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
undo staged changes
|
|
588
|
+
|
|
589
|
+
unstage file:
|
|
590
|
+
<terminal>git restore --staged filename.py</terminal>
|
|
591
|
+
|
|
592
|
+
unstage all:
|
|
593
|
+
<terminal>git restore --staged .</terminal>
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
undo commits (not pushed)
|
|
597
|
+
|
|
598
|
+
remove last commit, keep changes:
|
|
599
|
+
<terminal>git reset --soft HEAD~1</terminal>
|
|
600
|
+
|
|
601
|
+
remove last commit, discard changes:
|
|
602
|
+
<terminal>git reset --hard HEAD~1</terminal>
|
|
603
|
+
|
|
604
|
+
go back to specific commit:
|
|
605
|
+
<terminal>git reset --hard abc123</terminal>
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
undo pushed commits
|
|
609
|
+
|
|
610
|
+
create reversal commit:
|
|
611
|
+
<terminal>git revert abc123</terminal>
|
|
612
|
+
|
|
613
|
+
reverts changes in new commit.
|
|
614
|
+
safe for shared history.
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
PHASE 10: STASHING
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
when to stash
|
|
621
|
+
|
|
622
|
+
temporarily save work when:
|
|
623
|
+
- need to switch branches
|
|
624
|
+
- want to pull latest changes
|
|
625
|
+
- need to test something else
|
|
626
|
+
|
|
627
|
+
stash is a stack of temporary commits
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
basic stash
|
|
631
|
+
|
|
632
|
+
<terminal>git stash</terminal>
|
|
633
|
+
|
|
634
|
+
saves working directory and index.
|
|
635
|
+
returns to clean state.
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
view stashes
|
|
639
|
+
|
|
640
|
+
<terminal>git stash list</terminal>
|
|
641
|
+
|
|
642
|
+
stash@{0}: On main: add user login
|
|
643
|
+
stash@{1}: On feature: WIP on authentication
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
apply stash
|
|
647
|
+
|
|
648
|
+
<terminal>git stash apply</terminal>
|
|
649
|
+
|
|
650
|
+
applies most recent stash, keeps it in list.
|
|
651
|
+
|
|
652
|
+
apply specific stash:
|
|
653
|
+
<terminal>git stash apply stash@{1}</terminal>
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
drop stash
|
|
657
|
+
|
|
658
|
+
<terminal>git stash drop</terminal>
|
|
659
|
+
|
|
660
|
+
or combine:
|
|
661
|
+
<terminal>git stash pop</terminal>
|
|
662
|
+
|
|
663
|
+
applies and removes most recent stash.
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
stash with message
|
|
667
|
+
|
|
668
|
+
<terminal>git stash save "work on user auth"</terminal>
|
|
669
|
+
|
|
670
|
+
helpful for identifying stashes later
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
stash specific files
|
|
674
|
+
|
|
675
|
+
<terminal>git stash push -m "config changes" config.json</terminal>
|
|
676
|
+
|
|
677
|
+
only stashes specified file
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
PHASE 11: TAGGING
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
when to tag
|
|
684
|
+
|
|
685
|
+
mark releases:
|
|
686
|
+
- v1.0.0
|
|
687
|
+
- v1.1.0
|
|
688
|
+
- v2.0.0
|
|
689
|
+
|
|
690
|
+
tag production deployments
|
|
691
|
+
tag significant milestones
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
create tags
|
|
695
|
+
|
|
696
|
+
annotated (recommended):
|
|
697
|
+
<terminal>git tag -a v1.0.0 -m "Release version 1.0.0"</terminal>
|
|
698
|
+
|
|
699
|
+
lightweight:
|
|
700
|
+
<terminal>git tag v1.0.0</terminal>
|
|
701
|
+
|
|
702
|
+
annotated tags have message, date, author.
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
view tags
|
|
706
|
+
|
|
707
|
+
list all tags:
|
|
708
|
+
<terminal>git tag</terminal>
|
|
709
|
+
|
|
710
|
+
show tag details:
|
|
711
|
+
<terminal>git show v1.0.0</terminal>
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
push tags
|
|
715
|
+
|
|
716
|
+
push specific tag:
|
|
717
|
+
<terminal>git push origin v1.0.0</terminal>
|
|
718
|
+
|
|
719
|
+
push all tags:
|
|
720
|
+
<terminal>git push origin --tags</terminal>
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
delete tags
|
|
724
|
+
|
|
725
|
+
local:
|
|
726
|
+
<terminal>git tag -d v1.0.0</terminal>
|
|
727
|
+
|
|
728
|
+
remote:
|
|
729
|
+
<terminal>git push origin --delete v1.0.0</terminal>
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
checkout tags
|
|
733
|
+
|
|
734
|
+
view code at tag:
|
|
735
|
+
<terminal>git checkout v1.0.0</terminal>
|
|
736
|
+
|
|
737
|
+
creates detached HEAD state.
|
|
738
|
+
to work, create a branch:
|
|
739
|
+
<terminal>git checkout -b patch-1.0.1 v1.0.0</terminal>
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
PHASE 12: GITIGNORE
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
what to ignore
|
|
746
|
+
|
|
747
|
+
never commit:
|
|
748
|
+
- dependencies/ (node_modules, venv, __pycache__)
|
|
749
|
+
- build artifacts (.pyc, .o, .dll)
|
|
750
|
+
- environment files (.env, .env.local)
|
|
751
|
+
- ide settings (.idea/, .vscode/)
|
|
752
|
+
- os files (.DS_Store, Thumbs.db)
|
|
753
|
+
- logs (*.log)
|
|
754
|
+
- temporary files (*.tmp, *.swp)
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
create .gitignore
|
|
758
|
+
|
|
759
|
+
<terminal>cat > .gitignore << 'EOF'
|
|
760
|
+
# python
|
|
761
|
+
__pycache__/
|
|
762
|
+
*.py[cod]
|
|
763
|
+
*$py.class
|
|
764
|
+
.venv/
|
|
765
|
+
venv/
|
|
766
|
+
*.egg-info/
|
|
767
|
+
|
|
768
|
+
# environment
|
|
769
|
+
.env
|
|
770
|
+
.env.local
|
|
771
|
+
.env.*.local
|
|
772
|
+
|
|
773
|
+
# ide
|
|
774
|
+
.idea/
|
|
775
|
+
.vscode/
|
|
776
|
+
*.swp
|
|
777
|
+
*.swo
|
|
778
|
+
|
|
779
|
+
# os
|
|
780
|
+
.DS_Store
|
|
781
|
+
Thumbs.db
|
|
782
|
+
|
|
783
|
+
# logs
|
|
784
|
+
*.log
|
|
785
|
+
logs/
|
|
786
|
+
|
|
787
|
+
# testing
|
|
788
|
+
.coverage
|
|
789
|
+
htmlcov/
|
|
790
|
+
.pytest_cache/
|
|
791
|
+
|
|
792
|
+
# build
|
|
793
|
+
dist/
|
|
794
|
+
build/
|
|
795
|
+
*.egg
|
|
796
|
+
EOF</terminal>
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
existing .gitignore not working
|
|
800
|
+
|
|
801
|
+
files already tracked must be removed:
|
|
802
|
+
<terminal>git rm --cached filename</terminal>
|
|
803
|
+
|
|
804
|
+
for directory:
|
|
805
|
+
<terminal>git rm -r --cached directory/</terminal>
|
|
806
|
+
|
|
807
|
+
then commit.
|
|
808
|
+
|
|
809
|
+
|
|
810
|
+
ignore tracked file locally
|
|
811
|
+
|
|
812
|
+
<terminal>git update-index --assume-unchanged config.local.json</terminal>
|
|
813
|
+
|
|
814
|
+
keeps file locally, ignores for commits.
|
|
815
|
+
|
|
816
|
+
to undo:
|
|
817
|
+
<terminal>git update-index --no-assume-unchanged config.local.json</terminal>
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
PHASE 13: COMMON WORKFLOWS
|
|
821
|
+
|
|
822
|
+
|
|
823
|
+
feature branch workflow
|
|
824
|
+
|
|
825
|
+
1. update main
|
|
826
|
+
<terminal>git checkout main</terminal>
|
|
827
|
+
<terminal>git pull</terminal>
|
|
828
|
+
|
|
829
|
+
2. create feature branch
|
|
830
|
+
<terminal>git checkout -b feature/new-feature</terminal>
|
|
831
|
+
|
|
832
|
+
3. do work
|
|
833
|
+
<terminal># ... make changes ...</terminal>
|
|
834
|
+
<terminal>git add .</terminal>
|
|
835
|
+
<terminal>git commit -m "implement feature"</terminal>
|
|
836
|
+
|
|
837
|
+
4. update from main
|
|
838
|
+
<terminal>git fetch origin</terminal>
|
|
839
|
+
<terminal>git rebase origin/main</terminal>
|
|
840
|
+
|
|
841
|
+
5. resolve conflicts if any
|
|
842
|
+
|
|
843
|
+
6. push
|
|
844
|
+
<terminal>git push -u origin feature/new-feature</terminal>
|
|
845
|
+
|
|
846
|
+
7. create pull request
|
|
847
|
+
8. after merge, delete branch
|
|
848
|
+
<terminal>git branch -d feature/new-feature</terminal>
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
hotfix workflow
|
|
852
|
+
|
|
853
|
+
1. create hotfix from main
|
|
854
|
+
<terminal>git checkout main</terminal>
|
|
855
|
+
<terminal>git pull</terminal>
|
|
856
|
+
<terminal>git checkout -b hotfix/critical-bug</terminal>
|
|
857
|
+
|
|
858
|
+
2. fix the bug
|
|
859
|
+
<terminal># ... make minimal fix ...</terminal>
|
|
860
|
+
<terminal>git commit -m "fix: critical security issue"</terminal>
|
|
861
|
+
|
|
862
|
+
3. push and create expedited PR
|
|
863
|
+
<terminal>git push -u origin hotfix/critical-bug</terminal>
|
|
864
|
+
|
|
865
|
+
4. merge to main immediately
|
|
866
|
+
<terminal>git checkout main</terminal>
|
|
867
|
+
<terminal>git merge hotfix/critical-bug</terminal>
|
|
868
|
+
<terminal>git push</terminal>
|
|
869
|
+
|
|
870
|
+
5. tag release
|
|
871
|
+
<terminal>git tag -a v1.0.1 -m "Hotfix for security issue"</terminal>
|
|
872
|
+
<terminal>git push origin v1.0.1</terminal>
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
PHASE 14: REBASING FOR CLEAN HISTORY
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
interactive rebase
|
|
879
|
+
|
|
880
|
+
clean up last N commits:
|
|
881
|
+
<terminal>git rebase -i HEAD~3</terminal>
|
|
882
|
+
|
|
883
|
+
or:
|
|
884
|
+
<terminal>git rebase -i abc123</terminal>
|
|
885
|
+
|
|
886
|
+
opens editor with commands:
|
|
887
|
+
|
|
888
|
+
pick abc1234 first commit
|
|
889
|
+
pick def5678 second commit
|
|
890
|
+
pick ghi9012 third commit
|
|
891
|
+
|
|
892
|
+
commands:
|
|
893
|
+
- pick: keep as-is
|
|
894
|
+
- reword: edit commit message
|
|
895
|
+
- edit: pause for changes
|
|
896
|
+
- squash: combine with previous
|
|
897
|
+
- fixup: combine with previous, discard message
|
|
898
|
+
- drop: remove commit
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
squash related commits
|
|
902
|
+
|
|
903
|
+
before:
|
|
904
|
+
pick abc1234 add user model
|
|
905
|
+
pick def5678 fix user model typo
|
|
906
|
+
pick ghi9012 add user validation
|
|
907
|
+
|
|
908
|
+
after:
|
|
909
|
+
pick abc1234 add user model
|
|
910
|
+
fixup def5678 fix user model typo
|
|
911
|
+
fixup ghi9012 add user validation
|
|
912
|
+
|
|
913
|
+
result: one commit with message "add user model"
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
reorder commits
|
|
917
|
+
|
|
918
|
+
before:
|
|
919
|
+
pick abc1234 add feature
|
|
920
|
+
pick def5678 write tests
|
|
921
|
+
pick ghi9012 add documentation
|
|
922
|
+
|
|
923
|
+
after:
|
|
924
|
+
pick def5678 write tests
|
|
925
|
+
pick abc1234 add feature
|
|
926
|
+
pick ghi9012 add documentation
|
|
927
|
+
|
|
928
|
+
helps logical ordering
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
PHASE 15: RECOVERING FROM MISTAKES
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
reflog: find lost commits
|
|
935
|
+
|
|
936
|
+
<terminal>git reflog</terminal>
|
|
937
|
+
|
|
938
|
+
shows all git operations, including lost commits.
|
|
939
|
+
|
|
940
|
+
find the commit you want:
|
|
941
|
+
<terminal>git reflog | grep "commit message"</terminal>
|
|
942
|
+
|
|
943
|
+
restore it:
|
|
944
|
+
<terminal>git checkout abc123</terminal>
|
|
945
|
+
<terminal>git checkout -b recovered-branch</terminal>
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
recover dropped stash
|
|
949
|
+
|
|
950
|
+
<terminal>git fsck --no-reflog | grep "stash"</terminal>
|
|
951
|
+
|
|
952
|
+
or:
|
|
953
|
+
<terminal>git log --oneline --all --graph --stash</terminal>
|
|
954
|
+
|
|
955
|
+
recover:
|
|
956
|
+
<terminal>git stash apply abc123</terminal>
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
undo force push
|
|
960
|
+
|
|
961
|
+
if you force pushed and regret it:
|
|
962
|
+
|
|
963
|
+
find original reflog:
|
|
964
|
+
<terminal>git reflog origin/main</terminal>
|
|
965
|
+
|
|
966
|
+
reset to before force push:
|
|
967
|
+
<terminal>git reset --hard origin/main@{1}</terminal>
|
|
968
|
+
|
|
969
|
+
force push again (carefully!):
|
|
970
|
+
<terminal>git push --force</terminal>
|
|
971
|
+
|
|
972
|
+
|
|
973
|
+
recover deleted branch
|
|
974
|
+
|
|
975
|
+
<terminal>git reflog | grep "checkout: from"</terminal>
|
|
976
|
+
|
|
977
|
+
find where you were:
|
|
978
|
+
<terminal>git checkout abc123</terminal>
|
|
979
|
+
|
|
980
|
+
recreate branch:
|
|
981
|
+
<terminal>git checkout -b feature/lost-branch</terminal>
|
|
982
|
+
|
|
983
|
+
|
|
984
|
+
PHASE 16: GIT RULES (STRICT MODE)
|
|
985
|
+
|
|
986
|
+
|
|
987
|
+
while this skill is active, these rules are MANDATORY:
|
|
988
|
+
|
|
989
|
+
[1] NEVER commit broken code
|
|
990
|
+
tests must pass
|
|
991
|
+
code must work
|
|
992
|
+
no "wip" commits that break the build
|
|
993
|
+
|
|
994
|
+
[2] write meaningful commit messages
|
|
995
|
+
subject: what changed, imperative mood
|
|
996
|
+
body: why, if not obvious
|
|
997
|
+
reference issues: fixes #123
|
|
998
|
+
|
|
999
|
+
[3] pull before push
|
|
1000
|
+
integrate remote changes first
|
|
1001
|
+
avoid unnecessary merge commits
|
|
1002
|
+
<terminal>git pull --rebase</terminal>
|
|
1003
|
+
|
|
1004
|
+
[4] never force push to shared branches
|
|
1005
|
+
main, develop, release branches
|
|
1006
|
+
only force push your own feature branches
|
|
1007
|
+
<terminal>git push --force-with-lease</terminal>
|
|
1008
|
+
|
|
1009
|
+
[5] use branches for all work
|
|
1010
|
+
never commit directly to main
|
|
1011
|
+
feature branches, bugfix branches
|
|
1012
|
+
one branch per logical unit
|
|
1013
|
+
|
|
1014
|
+
[6] keep commits atomic
|
|
1015
|
+
one logical change per commit
|
|
1016
|
+
complete and working
|
|
1017
|
+
easy to review and revert
|
|
1018
|
+
|
|
1019
|
+
[7] review before committing
|
|
1020
|
+
<terminal>git diff</terminal>
|
|
1021
|
+
<terminal>git status</terminal>
|
|
1022
|
+
know what you're committing
|
|
1023
|
+
|
|
1024
|
+
[8] push frequently
|
|
1025
|
+
backup your work
|
|
1026
|
+
enable code review
|
|
1027
|
+
don't hold changes hostage
|
|
1028
|
+
|
|
1029
|
+
|
|
1030
|
+
PHASE 17: GIT SESSION CHECKLIST
|
|
1031
|
+
|
|
1032
|
+
|
|
1033
|
+
before starting work:
|
|
1034
|
+
|
|
1035
|
+
[ ] git status is clean
|
|
1036
|
+
[ ] on correct branch
|
|
1037
|
+
[ ] branch name is descriptive
|
|
1038
|
+
[ ] pulled latest from origin
|
|
1039
|
+
|
|
1040
|
+
while working:
|
|
1041
|
+
|
|
1042
|
+
[ ] commit often
|
|
1043
|
+
[ ] commit messages are clear
|
|
1044
|
+
[ ] tests pass before commit
|
|
1045
|
+
[ ] pushed to remote periodically
|
|
1046
|
+
|
|
1047
|
+
before creating PR:
|
|
1048
|
+
|
|
1049
|
+
[ ] branch is up to date with main
|
|
1050
|
+
[ ] rebase if needed
|
|
1051
|
+
[ ] no conflicts
|
|
1052
|
+
[ ] tests pass
|
|
1053
|
+
[ ] code is clean
|
|
1054
|
+
|
|
1055
|
+
after merge:
|
|
1056
|
+
|
|
1057
|
+
[ ] delete local branch
|
|
1058
|
+
[ ] delete remote branch
|
|
1059
|
+
[ ] pull latest main
|
|
1060
|
+
[ ] ready for next feature
|
|
1061
|
+
|
|
1062
|
+
|
|
1063
|
+
FINAL REMINDERS
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
git is your safety net
|
|
1067
|
+
|
|
1068
|
+
commit frequently
|
|
1069
|
+
push often
|
|
1070
|
+
small changes are easy to fix
|
|
1071
|
+
big changes are scary
|
|
1072
|
+
|
|
1073
|
+
|
|
1074
|
+
the golden rule
|
|
1075
|
+
|
|
1076
|
+
if you're unsure what will happen:
|
|
1077
|
+
<terminal>git status</terminal>
|
|
1078
|
+
<terminal>git diff</terminal>
|
|
1079
|
+
<terminal>git log --oneline -5</terminal>
|
|
1080
|
+
|
|
1081
|
+
know your state before acting
|
|
1082
|
+
|
|
1083
|
+
|
|
1084
|
+
when in doubt
|
|
1085
|
+
|
|
1086
|
+
branch is cheap
|
|
1087
|
+
create one and experiment
|
|
1088
|
+
you can always delete it
|
|
1089
|
+
your work is safe on main
|
|
1090
|
+
|
|
1091
|
+
|
|
1092
|
+
the goal
|
|
1093
|
+
|
|
1094
|
+
clean history
|
|
1095
|
+
clear intent
|
|
1096
|
+
easy to understand
|
|
1097
|
+
easy to collaborate
|
|
1098
|
+
|
|
1099
|
+
now go commit something great.
|