git
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| git [2026/06/07 00:19] – [commit] jhagstrand | git [2026/06/07 23:56] (current) – [Configuration] jhagstrand | ||
|---|---|---|---|
| Line 91: | Line 91: | ||
| The commit command creates a commit. | The commit command creates a commit. | ||
| - | Each commit is a version of the source code. | + | Each commit is a new version of the source code. |
| Initial edits to a text file are tentative. | Initial edits to a text file are tentative. | ||
| Line 112: | Line 112: | ||
| line 2 is blank, this is what signals git to split title and body | line 2 is blank, this is what signals git to split title and body | ||
| line 3+ is body, max 72 chars per line, hit enter to hardcode each newline | line 3+ is body, max 72 chars per line, hit enter to hardcode each newline | ||
| + | |||
| + | The commit message title style guide. | ||
| + | * Like a document sub-heading | ||
| + | * Imperative | ||
| + | * Start with capital letter, no period at the end | ||
| + | * No articles or filler | ||
| + | |||
| The history log of commit messages, combined with skillful use of the branch, merge, reset, and rebase commands enable a programmer to communicate to future developers exactly what he changed and how, why and when. | The history log of commit messages, combined with skillful use of the branch, merge, reset, and rebase commands enable a programmer to communicate to future developers exactly what he changed and how, why and when. | ||
| Line 128: | Line 135: | ||
| git show # details of latest commit | git show # details of latest commit | ||
| git tag -d 1.0 # delete a tag | git tag -d 1.0 # delete a tag | ||
| + | |||
| + | Tags are often used to implement public release versioning. | ||
| + | |||
| + | * Marketing Versioning, like macOS Sonoma | ||
| + | |||
| + | * Calendar Versioning, like 2026.06.04 | ||
| + | |||
| + | * Semantic Versioning (SemVer) | ||
| + | * see https:// | ||
| + | * major.minor.patch, | ||
| + | * minor and patch releases maintain backward compatibility | ||
| + | * as soon as backward compatibility is broken, the major number must be incremented | ||
| + | * important for a library with a public api, for example | ||
| + | |||
| + | (I remember the good old days, when broken backward compatibility was a sign of incompetence.) | ||
| + | |||
| ====worktree==== | ====worktree==== | ||
| Line 170: | Line 193: | ||
| The checkout command has two different functions. | The checkout command has two different functions. | ||
| - | ^ old | + | ^ old ^ new ^ |
| - | | git checkout < | + | | git checkout < |
| - | | git checkout < | + | | git checkout < |
| + | | git checkout < | ||
| The old checkout commands still work as always. | The old checkout commands still work as always. | ||
| + | (Note that checkout of a commit is extraordinary and results in a detached HEAD.) | ||
| ====diff==== | ====diff==== | ||
| Line 211: | Line 236: | ||
| git log --oneline --graph # shows a hierarchy of branches | git log --oneline --graph # shows a hierarchy of branches | ||
| + | ==== interactive rebase ==== | ||
| + | If you don't like the way the log looks now, the interactive rebase command lets you fix, reorder, drop and squash the commits, and reword the commit messages. | ||
| + | |||
| + | $ git switch mybranch | ||
| + | $ git rebase -i HEAD~3 | ||
| + | $ git rebase -i b619fca0 | ||
| + | |||
| + | The log is displayed in reverse chronological order. | ||
| + | |||
| + | The interactive rebase editor window displays the commits in chronological order. | ||
| + | |||
| + | A note about reordering the commits. | ||
| + | |||
| + | https:// | ||
| ===== How to use ===== | ===== How to use ===== | ||
| + | |||
| + | ==== Configuration ==== | ||
| + | |||
| + | Use git config --global to set name and email. | ||
| + | * Support anonymity by using a shielded email, like for example the private GitLab noreply masked email. | ||
| + | * Consider using a pair-programming persona as user.name to give credit to the AI author. | ||
| + | |||
| + | $ git config --global user.name "Your Name" | ||
| + | $ git config --global user.name "Your Name & Gemini 1.5 Flash" | ||
| + | $ git config --global user.email " | ||
| + | |||
| + | Aider automatically adds a Co-authored by: line to the body. Tell aider to skip that by adding parameters to .aider.conf.yml file: | ||
| + | attribute-author: | ||
| + | attribute-committer: | ||
| ====Create a new repository==== | ====Create a new repository==== | ||
git.1780805953.txt.gz · Last modified: 2026/06/07 00:19 by jhagstrand