.gitignore Everything by Default
151–160 of 185 posts
Re: .gitignore Everything by Default
#152This seems like bad advice. I've very rarely committed extra files by accident, but I would 100% forget to unignore files I meant to commit. If you're doing an initial setup step to gitignore everything, why not just do an initial setup step to gitignore the usual files? Make a template that you copy into all of your repos.
For many years I've have a git-ignored ".not-committed" folder in all of my repos for throwing extra anything into. It's been a huge life saver!
Re: .gitignore Everything by Default
#153Earlier quoted context omitted.
yes, but user level is not a repo level
Yes, but this is exactly the sort of thing that should be a user-level configuration. A personal scratch directory has nothing to do with the repository itself and doesn’t belong in a repo’s .gitignore. If it's only needed for one particular checkout, .git/info/exclude is the other obvious option.
Re: .gitignore Everything by Default
#154Re: .gitignore Everything by Default
#155Earlier quoted context omitted.
git add . is nondestructive and reversible. I tend to do git add . and then run git status. I’m far more interested in confirming my mental model of what I am about to commit if I git commit right now than my mental model of what will be added if I git add right now. If I didn’t already have that muscle memory I might try to switch to git add -v . which would tell me what files it added. I’d argue that a sane git wou…
No, ”git add .” is not easily reverted, there’s no git sub command for de-adding files from the staging area. You have to copy the whole folder (hope you have enough disk space), checking out an older commit (hard), and copy specific files from the copied folder. Pita. This is actually a general problem with git and most cli tools, where it would be possible and useful to undo an action, but the tool developer cannot…
Re: .gitignore Everything by Default
#156This seems like bad advice. I've very rarely committed extra files by accident, but I would 100% forget to unignore files I meant to commit. If you're doing an initial setup step to gitignore everything, why not just do an initial setup step to gitignore the usual files? Make a template that you copy into all of your repos.
For many years I've have a git-ignored ".not-committed" folder in all of my repos for throwing extra anything into. It's been a huge life saver!
Re: .gitignore Everything by Default
#157It is weird that quite a few developers comes up with advices where they seem to come from a world where they work alone, have not work with enough people, or with enough projects. In this case, a `.gitignore_global` takes care of the usual suspects that he mentioned `.DS_Store files, IDE config, compressed files, etc.`. Even if something goes wrong, it is usually caught during the initial scaffold before critical fi…
Wow, thanks so much for . gitignore_global. Finally can have Emacs files ignored automatically in all projects. <3
Please do.
Re: .gitignore Everything by Default
#158Earlier quoted context omitted.
Lazygit[0] is ideal for quickly selecting files or lines you want to include in your commit. There are probably countless others. And `--patch` is also not that hard. [0] https://github.com/jesseduffield/lazygit
Magit of course also solves this very nicely.
You can also select specific hunks or lines within a hunk to stage/unstage.
Re: .gitignore Everything by Default
#159 strict_ignore() {
[[ -n "$1" ]] || exit 1
local repo="${1%/}/"
local ignore
ignore=$(find "$repo" -path "$repo".git -prune -o -print \
| sed "s|$repo||g; /^$/d" \
| awk '{print "!"$0}' \
| sort)
printf "*\n%s\n" "$ignore"
}