aboutsummaryrefslogtreecommitdiff
path: root/programming
diff options
context:
space:
mode:
authoralex <alex@pdp7.net>2025-02-24 21:08:52 +0100
committeralexpdp7 <alex@corcoles.net>2025-02-24 21:09:43 +0100
commit731b3b221c39788488509cebf4a669ed3c082787 (patch)
tree03246d24f4425fa88e38387986e65be10154e47b /programming
parentb757281957c945f0a6c668b030b301933619a926 (diff)
Add Git advice
Diffstat (limited to 'programming')
-rw-r--r--programming/git/git_advice.md30
1 files changed, 30 insertions, 0 deletions
diff --git a/programming/git/git_advice.md b/programming/git/git_advice.md
new file mode 100644
index 00000000..2df2e07d
--- /dev/null
+++ b/programming/git/git_advice.md
@@ -0,0 +1,30 @@
+# Git advice
+
+## Never use `git commit -m`, use `git commit -v`
+
+Configure your system so that `git commit` opens your preferred editor.
+
+With `git commit -v` you can see your commit diff while writing your commit message.
+This helps you review that your commit is correct and write a better commit message.
+
+## Use a global gitignore
+
+See <https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration.html#_core_excludesfile>.
+
+I recommend that the `.gitignore` in a Git repository should only include files that the "supported" procedures for working of your repository generate.
+For example, `.gitignore` should exclude files generated by running or compiling the project.
+
+If your editor or operating system generates files in the repository, I suggest those are not excluded by the `.gitignore` in the repository, but on your personal global gitignore.
+
+This is more efficient:
+
+* You only have to add exclusions that you need once.
+* The project `.gitignore` is smaller and requires less mental overhead to maintain.
+
+## Use the modern Git commands (or teach them)
+
+Particularly, `git checkout` has many functionalities that now can be handled by more focused commands like `git switch` and `git reset`.
+
+If you have too much muscle memory and are used to them, then consider learning them only to teach other people so that they start with the safer commands.
+
+Many Git commands print suggestions that use the newer commands.