People who use "git commit -a" give me nightmares. Please don't do that.
Review your changes individually. Use "git add -p".
Yes, you may think you know all your changes and you even ran "git diff" five times: this innocent, one-line fuck-up is going to slip in at some point.
@fribbledom I will keep doing that. :D
Then I will "git add *" before immediately remembering that it does not apply to the current directory, but to the whole repository tree.
@Strit It’s easier to use just git commit -a. That way, you can write your commit message in an editor and make it longer, more meaningful and give it more thought than simply saying “Bug fixes” or “More improvements,” which is what most people tend to do when writing it from the command line.
At least, that’s my experience. YMMV.
@garritfra mkdir test
❯ cd test
❯ git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: git config --global init.defaultBranch <name>
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: git branch -m <name>
Initialized empty Git repository in /home/gxtony/test/.git/
❯ touch README
❯ git commit -a -m "initial commit"
On branch master
(use "git add <file>..." to include in what will be committed)
nothing added to commit but untracked files present (use "git add" to track)
@fribbledom on the one hand i don't do that, because i like to use git status as a pre-flight checklist. but on the other hand, having anything in the working set that's non-ignored and not to be included in the next commit gives _me_ nightmares
@fribbledom Can you point me at the reason for this? I'm not clear on why people do or don't use that option but have seen it recommended.
@fribbledom I run git status, git add (if needed) and git diff before git commit -a. I see nothing wrong with that.
@fribbledom It’s the flow I’m used to and it works for me. Of course, others may do things differently.
To me, git add -p intuitively seems more time-consuming, but maybe I’ll try it someday. To be honest, I didn’t know about it until you mentioned it.
git -am "A descriptive one-liner; the branch name references the development ticket" – or – git -am "A descriptive summary of the changes; the branch name references the development ticket" -m "A one-liner explaining one part better." -m "A one-liner explaining another part better." -m "Etc."
git add . if new files; git add -i if the circumstances require it (which is as good as never).
Server run by the main developers of the project It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!