@@ -278,6 +278,25 @@ gitGraph
278278</center >
279279
280280
281+ !!! circle-info "Useful ` git log ` variations"
282+
283+ ```bash
284+ # Compact one-line format
285+ git log --oneline
286+
287+ # Show last 5 commits
288+ git log -5
289+
290+ # Show changes in each commit
291+ git log -p
292+
293+ # Show commits by specific author
294+ git log --author="Dr. X"
295+
296+ # Show commits in date range
297+ git log --since="2 weeks ago"
298+ ```
299+
281300
282301### 8. ` git checkout ` — Switching branches
283302
@@ -332,13 +351,13 @@ gitGraph
332351
333352Once testing is complete, Dr. X merges their branch back into main.
334353
335- !!! terminal ""
336- ```bash # Switch to the branch you want to merge INTO
337- git checkout main
338-
339- # Merge the feature branch
340- git merge normalisation
341- ```
354+ ``` bash
355+ # Switch to the branch you want to merge INTO
356+ git checkout main
357+
358+ # Merge the feature branch
359+ git merge normalisation
360+ ```
342361
343362
344363### 10. ` git rebase ` — Keeping history tidy
@@ -363,8 +382,10 @@ flowchart LR
363382 D -.rebase.-> C'((C'))
364383 style C' fill:#fffbe6,stroke:#f90
365384```
385+ <small >Before <code >rebase</code ></small >
366386</center >
367387
388+
368389<center >
369390``` mermaid
370391%%{init: {'theme': 'base'}}%%
@@ -379,6 +400,7 @@ gitGraph
379400 checkout normalization
380401 merge main
381402```
403+ <small >After <code >rebase</code ></small >
382404</center >
383405
384406!!! warning "Golden rule of rebase"
@@ -413,38 +435,53 @@ flowchart LR
413435```
414436</center >
415437
416- ### 12. ` git reset ` — Undoing a mistake
438+ !!! circle-info "Useful ` stash ` commands"
417439
418- Oops — Dr.X accidentally committed a large ** matrix.mtx** test file.
419- They unstage it first:
440+ ```bash
441+ # List all stashes
442+ git stash list
420443
421- ``` bash
422- git reset matrix.mtx
423- ```
444+ # Apply stash without removing it
445+ git stash apply
424446
425- Then remove the bad commit:
447+ # Apply a specific stash
448+ git stash apply stash@{1}
426449
427- ``` bash
428- git reset --soft HEAD^
429- ```
450+ # Create a named stash
451+ git stash save "WIP: adding UMAP plots"
430452
431- If they want to completely delete it (be careful!):
453+ # Delete all stashes
454+ git stash clear
455+ ```
432456
433- ``` bash
434- git reset --hard HEAD^
435- ```
457+ ### 12. ` git reset ` — Undoing a mistake
436458
437- Reset moves the “HEAD pointer” to a previous commit — like discarding a failed experiment and reverting to known-good results .
459+ Oops — Dr. X accidentally committed a large ** matrix.mtx ** test file .
438460
439- <center >
440- ``` mermaid
441- %%{init: {'theme': 'base'}}%%
442- gitGraph
443- commit id: "Good commit"
444- commit id: "Bad commit" tag: "HEAD"
445- %% reset --hard HEAD^ moves HEAD back one step
446- ```
447- </center >
461+ There are three types of reset:
462+
463+ !!! terminal-2 "`--soft - : Undo commit, keep changes staged"
464+ ** Use when:** You want to recommit with a better message or add more files.
465+ ```bash
466+ # Undo last commit, keep changes in staging area
467+ git reset --soft HEAD^
468+ ```
469+
470+ !!! terminal-2 "` --mixed ` (default): Undo commit, unstage changes"
471+
472+ ** Use when:** You want to redo the commit but need to modify files first.
473+ ```bash
474+ # Undo last commit, move changes back to working directory
475+ git reset HEAD^
476+ # or
477+ git reset --mixed HEAD^
478+ ```
479+
480+ !!! terminal-2 "` --hard ` : Undo commit, delete changes"
481+ ```bash
482+ # Undo last commit and DELETE all changes (be careful!)
483+ git reset --hard HEAD^
484+ ```
448485
449486
450487## Common Questions
0 commit comments