News for hackers. Stuff that matters.
Re:Git ignores .gitignore with .gitignore in .gitignore by rpigab on Wednesday May 18, 2022 @04:27AM (#31420432)
This is my favourite feature of gitignores. Everytime I need "drafts", sample code, etc, in a repo, I create a folder in that repo, but then I have to remember to not add it to commits, and I don't want to add it to the .gitignore that is versioned, so I do "mkdir drafts && echo '*' > ./drafts/.gitignore", and it ignores my drafts without having to add a new ignored dir in the versioned .gitignores.

And obviously, it also "ignores" the .gitignore itself because it matches "*", while still taking it into account, which is what I need.

Re:Git ignores .gitignore with .gitignore in .gitignore by Dobbs on Wednesday May 18, 2022 @04:41AM (#31420509)
Additionally git supports a global git ignore.

    $ git config --global core.excludesfile ~/.gitignore
Then you can put all the standard things you want to ignore into it:

    $ cat ~/.gitignore
    .DS_Store
    ./drafts/
    *.swp
And it will apply to all git commands on your computer.
Re:Git ignores .gitignore with .gitignore in .gitignore by tehbeard on Wednesday May 18, 2022 @10:50AM (#31423511)
I heavily advise AGAINST using this for anything apart from OS level file spam (.DS_Store etc).

We spent a good part of a day rebuilding a repo after a junior dev. left, when we found out they'd misused global gitignore and hadn't commited several important files due to an ignore they had set for a seperate project.

Lessons learnt. Ensure new devs don't use it, and code review on another machine than theirs...

Re:Git ignores .gitignore with .gitignore in .gitignore by fishywang on Wednesday May 18, 2022 @01:13PM (#31425210)
If they did not commit all the important files and your CI system didn't catch that, that's definitely the fault of your CI system, not global gitignore.
Re:Git ignores .gitignore with .gitignore in .gitignore by tehbeard on Friday May 20, 2022 @02:01AM (#31443887)
Because there isn't a CI?

Shocking I know /s.

But not everyone on here is part of a 20 man SV tech startup making the next social media for beagles and deploying 50 times a day...

Re:Git ignores .gitignore with .gitignore in .gitignore by Dobbs on Friday May 20, 2022 @07:06PM (#31453657)
You don’t have to be at a tech startup to have things like CI and/or code review platforms.
Re:Git ignores .gitignore with .gitignore in .gitignore by aynawn on Saturday May 21, 2022 @10:17AM (#31458139)
Agreed. If the code is in GitHub, it's incredibly easy to create a simple github actions workflow that could run the app.
Re:Git ignores .gitignore with .gitignore in .gitignore by llllllllllll9 on Wednesday May 18, 2022 @04:55PM (#31427539)
so glad i don't work with you.
Re:Git ignores .gitignore with .gitignore in .gitignore by xxpor on Wednesday May 18, 2022 @05:09PM (#31427704)
Why? They're right imo
Re:Git ignores .gitignore with .gitignore in .gitignore by llllllllllll9 on Thursday May 19, 2022 @09:36PM (#31442375)
fishywang's attitude
Re:Git ignores .gitignore with .gitignore in .gitignore by SZJX on Sunday May 22, 2022 @02:20PM (#31471158)
What attitude lmao. They’re very matter-of-fact in expressing an objective opinion from what I can see.
Re:Git ignores .gitignore with .gitignore in .gitignore by llllllllllll9 on Wednesday May 25, 2022 @03:14PM (#31509191)
what perceptive skills lmao! i couldn't stand talking to you for 2 minutes.

lmao!

Re:Git ignores .gitignore with .gitignore in .gitignore by OrderlyTiamat on Thursday May 19, 2022 @03:18AM (#31431673)
I don't understand, you'd rather work without a CI pipeline?
Re:Git ignores .gitignore with .gitignore in .gitignore by llllllllllll9 on Thursday May 19, 2022 @09:37PM (#31442377)
i'd rather not work with fishywang
Re:Git ignores .gitignore with .gitignore in .gitignore by runarberg on Wednesday May 18, 2022 @11:38AM (#31424105)
You might have learned the wrong lesson.

A broken code should not be able to make it to production, there should be several steps to prevent that, including: Peer review, CI, QA, a staging environment, manual testing, etc.

Always assume that developers can screw up in trivial ways, and build your delivery system such that trivial screw ups will be caught early, rather then dictate how your devs setup their work stations.

Also don’t code review the code it self, review the diff.

Re:Git ignores .gitignore with .gitignore in .gitignore by nullgeo on Wednesday May 18, 2022 @03:21PM (#31426595)
Yeah exactly, if I `require important.rb` in this file, and `important.rb` wasn't committed how did that project even build and get deployed. Any sane build system will instantly fail for this situations. Looks like an issue with dev ops/engineering culture rather than .gitignore
Re:Git ignores .gitignore with .gitignore in .gitignore by someweirdperson on Wednesday May 18, 2022 @04:54PM (#31427533)
>Also don’t code review the code it self, review the diff.

A significant percentage of the most critical problems I detect during reviews is in the parts that have not been changed, invisible in the diff. A good diff is necessary, but not sufficient.

Re:Git ignores .gitignore with .gitignore in .gitignore by bmitc on Wednesday May 18, 2022 @12:54PM (#31425000)
Telling developers to not use the global .gitignore seems to be the wrong response. For example, I use VS Code, its extensions, and various other development tools that create local files that should not be in repositories. Those files and directories do not belong in a repository's .gitignore file, unless it's a personal project. They most often belong in a global .gitignore unless a team uses a common set of tools. Having a single developer's custom tools be handled by a repository's .gitignore seems to be the wrong approach.
Re:Git ignores .gitignore with .gitignore in .gitignore by Fatnino on Wednesday May 18, 2022 @05:00PM (#31427592)
.git/info/exclude seems like the right place for this.
Re:Git ignores .gitignore with .gitignore in .gitignore by bmitc on Wednesday May 18, 2022 @05:08PM (#31427686)
That's only per repository, isn't it? It won't really be convenient when you're working across several repositories or languages.
Re:Git ignores .gitignore with .gitignore in .gitignore by sitzkrieg on Wednesday May 18, 2022 @10:54AM (#31423552)
how did that project ever build on ci :)
Re:Git ignores .gitignore with .gitignore in .gitignore by xyst on Wednesday May 18, 2022 @11:30AM (#31424010)
hint: there was no CI
Re:Git ignores .gitignore with .gitignore in .gitignore by superjan on Wednesday May 18, 2022 @12:05PM (#31424435)
I heavily advise AGAINST not using CI. If properly applied it solves .gitignore mistakes and many more, made by those infamous junior devs. On second thought, not just juniors. Oh well.
Re:Git ignores .gitignore with .gitignore in .gitignore by 89vision on Wednesday May 18, 2022 @11:16AM (#31423853)
but it worked on my machine
Re:Git ignores .gitignore with .gitignore in .gitignore by abustamam on Wednesday May 18, 2022 @12:59PM (#31425061)
Ship your machine as CI, problem solved /s
Re:Git ignores .gitignore with .gitignore in .gitignore by rubyist5eva on Wednesday May 18, 2022 @01:07PM (#31425150)
docker wants to know your location
Re:Git ignores .gitignore with .gitignore in .gitignore by TheSoftwareGuy on Wednesday May 18, 2022 @03:54PM (#31426912)
Probably the dev made the code review before leaving
Re:Git ignores .gitignore with .gitignore in .gitignore by alexpls on Wednesday May 18, 2022 @06:58AM (#31421254)
The global gitignore is super useful! I add a “.x” entry to it so that I can create scripts, drafts, etc in a “.x” folder in any of my projects.

Wrote more details about how I do this here: https://alexplescan.com/posts/2022/04/17/the-x-files/

Re:Git ignores .gitignore with .gitignore in .gitignore by sdoering on Wednesday May 18, 2022 @08:37AM (#31422003)
You had me - before clicking - at the url-slug "the-x-files". Loved the content and learned something useful. Thanks for pointing it out. Will be another little tool in my belt.
Re:Git ignores .gitignore with .gitignore in .gitignore by wonder_er on Wednesday May 18, 2022 @11:38AM (#31424104)
just set this up on my machine! Thank you so much!

I'd just been bumping into this problem, but hadn't conceptualized such an elegant solution, so kept fumbling around, adding/moving things, futzing around with git way more than I wanted to.

Thank you!

Re:Git ignores .gitignore with .gitignore in .gitignore by p1necone on Wednesday May 18, 2022 @05:37AM (#31420761)
This seems like it could potentially be a source of confusion - different devs on the same project would see different ignore behavior.
Re:Git ignores .gitignore with .gitignore in .gitignore by dundarious on Wednesday May 18, 2022 @08:07AM (#31421744)
In many ways that’s a good thing. I don’t want to have ignore entries for 10 different text editors in every project’s .gitignore. Put that stuff in your personal .gitignore. In general, I don’t want commit history to contain any of these “just for me” changes even aside from .gitignore. Project .gitignore should mostly just ignore the stuff that your build/CI produces, which itself should hopefully be just a single `build` directory.
Re:Git ignores .gitignore with .gitignore in .gitignore by diarrhea on Wednesday May 18, 2022 @06:37AM (#31421105)
As far as I can see, this only comes into play when newly adding files to be tracked. If you created a 'source.file', but your global gitignore ignores all '.file' files, then you'd notice immediately. You wouldn't commit and push because you were unable to add the file in the first place.

If another developer has added a 'source.file' and you pulled it in, your global gitignore would not be triggered, since the file is already tracked in the repo.

Re:Git ignores .gitignore with .gitignore in .gitignore by CorrectHorseBat on Wednesday May 18, 2022 @07:24AM (#31421425)
It would also come into play of you add code that generates files which should be ignored, but you don't realize the gitignore has to be updated because it's ignored in your own global gitignore.
Re:Git ignores .gitignore with .gitignore in .gitignore by diarrhea on Wednesday May 18, 2022 @07:44AM (#31421564)
Very good observation. That's a reason I'm itching to try out an approach akin to this (in a future project): https://jasonstitt.com/gitignore-whitelisting-patterns
Re:Git ignores .gitignore with .gitignore in .gitignore by nishs on Wednesday May 18, 2022 @10:02AM (#31422889)
Excellent point!

Tangentially, to prevent scenarios where generated code becomes out of sync, in your CI you should always re-run generators and check that `git status` shows no entries (and fail the build if it does).

Re:Git ignores .gitignore with .gitignore in .gitignore by RHSeeger on Wednesday May 18, 2022 @08:35AM (#31421982)
I am surprised this isn't expected. Sure, it's nice to have common build files ignored. But I have all kinds of files locally (editor files, etc) that are specific to me, not common to my team. I don't expect my team to have the same ignore list as me, nor would I want my ignore list cluttered with entries that only apply to them. I see it the same as an editor/IDE config; each person has their own, and putting them in version control tends to cause issues/noise.
Re:Git ignores .gitignore with .gitignore in .gitignore by mirceal on Wednesday May 18, 2022 @09:50AM (#31422749)
Is this a problem though? I can see the upsides of ignoring the files in the shared gitignore. Are we trying to save space??
Re:Git ignores .gitignore with .gitignore in .gitignore by dahart on Wednesday May 18, 2022 @11:12AM (#31423785)
Yes it is a problem when a project involves more than a few people. If there are really common ignores that multiple people use, it’s fine to share those. But one-off folder & file ignores should not be dumped into the shared space. It has nothing to do with disk space, and everything to do with clean semantic project organization. Shared ignores should be primarily a declaration of temporary files & folders that the project produces during build/run/etc. - things that everyone will need. Adding personal folder ignores to the shared .gitignore can not only be confusing about what intermediate artifacts are expected, it can cause problems or conflicts for other people. A small dumb example is if someone tries to make a new shared folder and someone else already shared an ignore. I’ve seen it happen, and it’s not a big deal, but caused temporary confusion. You can cause issues with git history and pulls and bisects when there’s churn with the ignores.
Re:Git ignores .gitignore with .gitignore in .gitignore by mirceal on Wednesday May 18, 2022 @11:47AM (#31424204)
Back on earth, a few lines in an ignore file would not make anyone blink. I guess you're a purist and everything about your software shines! Perfection.
Re:Git ignores .gitignore with .gitignore in .gitignore by dahart on Wednesday May 18, 2022 @12:33PM (#31424769)
> Back on earth, a few lines in an ignore file would not make anyone blink. I guess you're a purist and everything about your software shines! Perfection.

I didn’t downvote you, and I don’t understand your sarcasm toward me when I’m trying to explain the practical answer to the question you asked. This isn’t just a few lines on a large project, and it’s not even about the extra lines at all. The issue is that personal preferences don’t belong in a shared file, and their presence can cause real and actual problems in a large project, problems I’ve witnessed and experienced first hand. One single bad line in .gitignore can cause trouble for everyone on the team when they need to checkout different branches. If you have 50 or 100 people adding their own ignores, they can and do easily conflict with each other. The shared .gitignore just isn’t the spot to list your personal folders, which is why git designed other places for you to put those.

Re:Git ignores .gitignore with .gitignore in .gitignore by gvx on Wednesday May 18, 2022 @07:09AM (#31421320)
As long as you know your own ignore behaviour, I don't see how it can cause confusion... except maybe if you share the drive the repo is stored (either as a network drive or you share the physical drive via sneakernet) but why would you do that instead of cloning the repo?
Re:Git ignores .gitignore with .gitignore in .gitignore by dahart on Wednesday May 18, 2022 @11:00AM (#31423644)
This is by design, and not a problem in practice: ignores are declaring unshared files & folders. If ignores change the state or behavior of the project, it means someone didn’t use ignores correctly, didn’t think through what ignore behavior should be shared and what shouldn’t. Sometimes there are folders everyone will have that should be ignored, like a “build/“ folder, and sometimes there are folders you make yourself inside your repo and don’t want them checked in, like test scripts or output images or whatever. The personally ignored artifacts should be different ignore behavior.
Re:Git ignores .gitignore with .gitignore in .gitignore by fishywang on Wednesday May 18, 2022 @01:40PM (#31425510)
Global gitignore should in general only be used for things that's "unique" in your local environment, like:

* IDE/Editor (for example, add `.vscode` to your global gitignore if you use VSCode, add `.idea` if you use IntelliJ family, NOT add `.editorconfig` because that's intended to be cross environment)

* OS level spam (`.DS_Store`, etc.)

* Any file generated by a tool you use locally

Also a pro tip, I have this alias in my global git config:

    why-ignore = check-ignore -v --no-index
So I can use `git why-ignore path/to/file` to show why a file is ignored (e.g. it shows which line in which gitignore file excluded it).
Re:Git ignores .gitignore with .gitignore in .gitignore by fomine3 on Wednesday May 18, 2022 @10:09PM (#31429899)
Thanks for pro tip, git clean -ndx is my friend.
Re:Git ignores .gitignore with .gitignore in .gitignore by rjmunro on Wednesday May 18, 2022 @05:44AM (#31420800)
Not really, because they only see differences they have caused themselves, so they know about it.
Re:Git ignores .gitignore with .gitignore in .gitignore by xcambar on Wednesday May 18, 2022 @06:03AM (#31420922)
And so they forget about it.
Re:Git ignores .gitignore with .gitignore in .gitignore by malingo on Wednesday May 18, 2022 @08:32AM (#31421957)
I agree. The same problem (different devs with different settings) is solved by specifying line endings in per-repo .gitattributes files instead of global autocrlf settings. And we all know how much confusion that causes.
Re:Git ignores .gitignore with .gitignore in .gitignore by lozenge on Wednesday May 18, 2022 @07:32AM (#31421470)
I wouldn't use this for system files, but I have the pattern "loz_*" and it lets me keep "my" odd scripts in the repo folder but permanently untracked.
Re:Git ignores .gitignore with .gitignore in .gitignore by trey-jones on Wednesday May 18, 2022 @08:18AM (#31421817)
This is the reality of the global .gitignore. Unless you have a full team of super competent and well rounded devs that think alike, one is going to come up with a strategy of "ok, everyone should obviously put stuff like .vscode in their global gitignore; it has no place in the local one" while somebody else doesn't care a bit, and it's really kind of a silly thing to try and enforce protocol around. Much bikeshedding detected.
Re:Git ignores .gitignore with .gitignore in .gitignore by izietto on Wednesday May 18, 2022 @05:44AM (#31420801)
It is as soon as you forget about that-but, speaking of myself, it is not because I'm aware of the fact that I'm using it
Re:Git ignores .gitignore with .gitignore in .gitignore by sph on Wednesday May 18, 2022 @05:08AM (#31420636)
I also got in my ~/.gitignore:

    .envrc   # direnv, where I store my local project configuration
    .vscode
and when I remember to use them:

    *.gitlocal
    *.gitlocal*
To store files and directories I don't ever want to push, mostly for scratch files and logs
Re:Git ignores .gitignore with .gitignore in .gitignore by AlfeG on Wednesday May 18, 2022 @06:13AM (#31420976)
Why to ignore .vscode? We collect there workspace wide team settings.
Re:Git ignores .gitignore with .gitignore in .gitignore by sph on Wednesday May 18, 2022 @06:18AM (#31421006)
I don't think editor-related settings should be committed, unless it's a company repo and everybody is forced to use the same editor. Otherwise all projects would be littered with .vscode, .atom, .sublime, .dir-locals.el, etc. which isn't great.

Anyway, stuff in .gitignore can still be added to the index if you so wish.

Re:Git ignores .gitignore with .gitignore in .gitignore by downsidesabound on Wednesday May 18, 2022 @07:32AM (#31421471)
If almost everyone uses some editor, then it’s not really “littered”. We do the same and it’s nice for new teammates to quickly get set up. If they are one of the few folks that want to use some other editor, who cares? Files are free.
Re:Git ignores .gitignore with .gitignore in .gitignore by pjerem on Wednesday May 18, 2022 @08:42AM (#31422039)
When almost everyone uses the same editor, it doesn't mean that everyone wants to have the same configuration.

Editors and IDEs are crafting tools. Crafting tools are meant to be mastered by workers (here: developers), not to enforce some team/company policy.

There are tools that already exists to enforce team policies like formatters, linters and so on. These tools generally integrate well with your editor of choice and can also be integrated on your CI pipelines.

Re:Git ignores .gitignore with .gitignore in .gitignore by ascagnel_ on Wednesday May 18, 2022 @09:31AM (#31422533)
I feel like a better option than committing is to have developers submit sample configurations and make them available in a subfolder or a dedicated configuration repo -- this way, newcomers to the team can pull in existing configurations and tweak them, rather than having to start from zero.
Re:Git ignores .gitignore with .gitignore in .gitignore by sph on Wednesday May 18, 2022 @08:46AM (#31422064)
I said it makes sense iff everyone uses the same editor and the same settings. But many times this is not the case.

What do you need to share btw? There's editorconfig, prettier, git hooks, etc. for style. direnv for configuration (I usually commit a .envrc.example file). I can't think of anything else.

Re:Git ignores .gitignore with .gitignore in .gitignore by roykanesmith37 on Wednesday May 18, 2022 @11:07AM (#31423735)
At my last job we had a mono-repo with the .idea directory (for IntelliJ) commited. For Java projects IntelliJ needs to sometimes be directed to understand what folders are “resources” to allow better autocompletion and highlighting.

For example specifying custom java faces components directory that will be used once the application is packaged into a war file, so IntelliJ knows they are accessible from JSP html files, and will autocomplete and show you what attributes you can modify on the component.

Re:Git ignores .gitignore with .gitignore in .gitignore by shagie on Wednesday May 18, 2022 @11:51AM (#31424260)
I had a dev check in their .idea directory and all the files for a project. This resulted in them checking in the file that had windows and cursor positions checked in too. Each time you went to switch to a different branch, you got the workspace configuration of the last person to commit that file.

Another spot of problems was the plugin specific files (that inevitably also got checked in). When someone checked them in again and you hadn't updated this particular plugin, the newer file format caused it to crash. Not a problem for the dev who checked it in, but a problem for everyone else.

I am a strong proponent now of not checking in files that are IDE specific unless the developers are all completely aware of what files do what and the associated churn that a file may have through normal use.

Having maven and editorconfig instruct IntelliJ on how to make a workspace consistent results in less config file churn and avoids people accidentally checking in the compiler settings on their computer, database configurations (with passwords), run configurations (with passwords) and similar.

Checking in IDE files can be done, just that the developers all need to be diligent in checking what they check in. I've rarely been in an environment where that is the case for everyone.

Re:Git ignores .gitignore with .gitignore in .gitignore by abdouls on Wednesday May 18, 2022 @08:40AM (#31422019)
I've seen a few big repositories upload their .vscode (pretty sure at least one of the Microsoft repos on Github had this).

I have a few team who does commit their .vscode folder, they use it to set up their environment the same way (usually when a project differs from another).

Re:Git ignores .gitignore with .gitignore in .gitignore by bloopernova on Wednesday May 18, 2022 @09:38AM (#31422604)
What about .editorconfig?
Re:Git ignores .gitignore with .gitignore in .gitignore by sph on Wednesday May 18, 2022 @11:36AM (#31424077)
That's perfectly fine, mandatory even if more than one person touches the code.
Re:Git ignores .gitignore with .gitignore in .gitignore by blueberrychpstx on Wednesday May 18, 2022 @09:47AM (#31422722)
you didn't list .idea :'(
Re:Git ignores .gitignore with .gitignore in .gitignore by junon on Wednesday May 18, 2022 @07:19AM (#31421379)
Please never commit IDE config. It doesn't belong in repositories. It is not a source file of your project.
Re:Git ignores .gitignore with .gitignore in .gitignore by dougdonohoe on Wednesday May 18, 2022 @07:47AM (#31421587)
Actually, this can be quite useful (at least with IntelliJ) to share common run configurations (e.g., run all tests, start this server with these settings) and other settings.

IntelliJ recommends not checking in a few types of files that are specific to the individual: https://intellij-support.jetbrains.com/hc/en-us/articles/206...

Re:Git ignores .gitignore with .gitignore in .gitignore by sph on Wednesday May 18, 2022 @08:50AM (#31422094)
Makefile or adding those scripts to package.json is a much better idea than vscode's own task configuration file which might not work if someone uses another editor.
Re:Git ignores .gitignore with .gitignore in .gitignore by fomine3 on Wednesday May 18, 2022 @10:11PM (#31429918)
Why not both?
Re:Git ignores .gitignore with .gitignore in .gitignore by jameshart on Wednesday May 18, 2022 @09:15AM (#31422374)
'never' is a strong word.

A .vscode/extensions.json file just specifies extension 'recommendations', and I find, really accelerates developers becoming productive in a project.

If I want to encourage small, one-off contributions, I want to support a user workflow that's as close as possible to:

   git clone <project>
   git switch -t <branch>
   code <project>
   npm ci | dotnet restore | terraform init | go get | <whatever>
   <change and test>
   git add <changes>
   git commit
   git push
With the right set of extension recommendations and default code settings, a VS code user can automatically be prompted to get the right test executors, linters, prettifiers, and so on so that they get instant feedback on their changes.

It doesn't even matter if many users who work on the codebase day to day actually use emacs or a highly customized IntelliJ setup or whatever - the vscode settings specifically enable the driveby coder to get a working environment fast, and that helps enable the power users to not be bothered by feature requests that could be pull requests.

Re:Git ignores .gitignore with .gitignore in .gitignore by junon on Wednesday May 18, 2022 @09:52AM (#31422782)
Never is a strong word, and I mean it. No your fancy extensions mean nothing to many devs. That configuration is not required to run the code in the repository. Do not include it.
Re:Git ignores .gitignore with .gitignore in .gitignore by roykanesmith37 on Wednesday May 18, 2022 @11:11AM (#31423772)
Java projects can get complex and editors (like IntelliJ can provide much better tooling when configured).

At my last job we had a mono-repo with the .idea directory (for IntelliJ) commited. For Java projects IntelliJ needs to sometimes be directed to understand what folders are “resources” to allow better autocompletion and highlighting. For example specifying custom java faces components directory that will be used once the application is packaged into a war file, so IntelliJ knows they are accessible from JSP html files, and will autocomplete and show you what attributes you can modify on the component.

It’s definitely not a never situation. You can commit only certain files from the configuration (project settings not editor preferences)

Re:Git ignores .gitignore with .gitignore in .gitignore by jameshart on Wednesday May 18, 2022 @10:43AM (#31423405)
So... are you also against having any hints as to how to set up a working local dev environment in the README.md file? Because that's also not necessary to run the project, but it's a courtesy to contributors.

Also, the idea that there is some universal rule of 'what should be checked in to source control' that applies to EVERYTHING from personal projects to corporate internal monorepos to open source projects to undergrad joint coding projects to video games is... absurd.

Re:Git ignores .gitignore with .gitignore in .gitignore by junon on Wednesday May 18, 2022 @11:44AM (#31424172)
No, because that's documentation, but I think that was obvious.
Re:Git ignores .gitignore with .gitignore in .gitignore by jameshart on Wednesday May 18, 2022 @11:47AM (#31424206)
Well, no it's not obvious.

If I can provide machine readable documentation on how to get your VSCode environment set up (in the form of a .vscode/extensions.json file), isn't that strictly better than merely human-readable documentation in README.md under a 'Recommended VSCode Extensions to work with this project' header?

Re:Git ignores .gitignore with .gitignore in .gitignore by junon on Wednesday May 18, 2022 @12:41PM (#31424857)
No, because that doesn't translate to other IDEs and one user programmatically changing things to suit themselves causes fluff in PRs and diffs. You also can't guarantee every environment is going to respond correctly.
Re:Git ignores .gitignore with .gitignore in .gitignore by Hackbraten on Wednesday May 18, 2022 @01:19PM (#31425266)
One user programmatically changing things to suit themselves is supposed to do so in their user settings, which has precedence over the checked-in copy. That way, you have the best of both worlds: easy set-up for everyone who wants it but you can override it without touching the VCS.
Re:Git ignores .gitignore with .gitignore in .gitignore by Hackbraten on Thursday May 19, 2022 @03:34PM (#31439083)
Update: turns out the precedence rules are a little more subtle than I thought.

See also: https://code.visualstudio.com/docs/getstarted/settings#_sett...

Re:Git ignores .gitignore with .gitignore in .gitignore by DangitBobby on Thursday May 19, 2022 @12:17AM (#31430706)
Can you override user settings at the project level?
Re:Git ignores .gitignore with .gitignore in .gitignore by Hackbraten on Thursday May 19, 2022 @03:33PM (#31439057)
Yes, project-level (aka workspace) settings generally override user settings.

But then again, language-specific settings will trump all other settings. And that’s one way to override workspace-level settings in your user settings if you want.

Here’s a detailed list of all levels of settings in VS Code, ordered by precedence: https://code.visualstudio.com/docs/getstarted/settings#_sett...

Re:Git ignores .gitignore with .gitignore in .gitignore by jonnycomputer on Wednesday May 18, 2022 @12:49PM (#31424932)
I think I disagree, though the only person who should be messing with it is the maintainer. One of the easiest ways to ensure that everyone follows the same coding standard for a project (particularly for open source projects).

I usually add something like specified in:

https://editorconfig.org/

Re:Git ignores .gitignore with .gitignore in .gitignore by junon on Wednesday May 18, 2022 @04:42PM (#31427381)
But there's a difference between editorconfig and vscode specific stuff in that editorconfig is IDE agnostic...
Re:Git ignores .gitignore with .gitignore in .gitignore by jonnycomputer on Wednesday May 18, 2022 @05:28PM (#31427909)
Yes; would be silly to dictate people's font sizes and the like. Perhaps we can then agree that there are certain configs that do belong, and others that might be less wise to include [if your boss dictates that you use Arial 10pt, get another job!]
Re:Git ignores .gitignore with .gitignore in .gitignore by rubyist5eva on Wednesday May 18, 2022 @02:42PM (#31426196)
For the love of God no. I had someone commit theirs and it override my preferred setup and even changed my gd font. You're basically telling your teammates: i am forcing you to work my way so shove it.
Re:Git ignores .gitignore with .gitignore in .gitignore by dharmab on Wednesday May 18, 2022 @11:25AM (#31423950)
Most teams I worked on did not standardize the team's OS or editor. The "canonical" build was a CI server and the development environment was available as a VM or container.
Re:Git ignores .gitignore with .gitignore in .gitignore by EmileSonneveld on Thursday May 19, 2022 @04:20AM (#31432051)
I do the same with with *gitignored*. Handy for output files of tests, and log files. For example: "log_gitignored.txt" or "mesh_transformed_gitignored.stl".

I add it to the repository settings, so all collogues have the same behavior.

Re:Git ignores .gitignore with .gitignore in .gitignore by vbezhenar on Wednesday May 18, 2022 @05:57AM (#31420883)
Standard path is ~/.config/git/ignore
Re:Git ignores .gitignore with .gitignore in .gitignore by toastal on Wednesday May 18, 2022 @07:35AM (#31421495)
You mean $XDG_CONFIG_HOME/git/ignore
Re:Git ignores .gitignore with .gitignore in .gitignore by carlhjerpe on Wednesday May 18, 2022 @09:24AM (#31422456)
"For writing options: write to global ~/.gitconfig file rather than the repository .git/config, write to $XDG_CONFIG_HOME/git/config file if this file exists and the ~/.gitconfig file doesn’t."

Everyone aren't using all the freedesktop conventions, so no.

Re:Git ignores .gitignore with .gitignore in .gitignore by everybodyknows on Wednesday May 18, 2022 @11:54AM (#31424297)
To supply context: the above quote is from the man page, therefore authoritative.

  $ man git-config
It is however densely conditional wording -- could be simplified.
Re:Git ignores .gitignore with .gitignore in .gitignore by vbezhenar on Wednesday May 18, 2022 @12:16PM (#31424564)
I don't think that XDG_CONFIG_HOME is a thing with Windows or macOS.
Re:Git ignores .gitignore with .gitignore in .gitignore by gertlex on Wednesday May 18, 2022 @09:34AM (#31422572)
I've got a slightly different version of that last rule in mine:

    *.sw?
Since I'm messy enough to sometimes end up with multiple of them for a few files. (Also, not messing with flash files in git, or in general...)

But have since moved my vim swap files to ~/.vim/swap with `set directory=~/.vim/swap,.` in .vimrc.

Re:Git ignores .gitignore with .gitignore in .gitignore by fomine3 on Wednesday May 18, 2022 @10:13PM (#31429923)
ignoring .swf is a bonus :P
Re:Git ignores .gitignore with .gitignore in .gitignore by mikl on Wednesday May 18, 2022 @04:08PM (#31427040)
Or simply put the file at the default location for core.excludefile, which is

    ~/.config/git/ignore 
on Unixy platforms.
Re:Git ignores .gitignore with .gitignore in .gitignore by chrisfinazzo on Wednesday May 18, 2022 @10:03AM (#31422907)
Hard agree. Even though I tend to work on only a couple of different kinds of things - at least for now - the global ignore file is a godsend.

So good.

Re:Git ignores .gitignore with .gitignore in .gitignore by RupertWiser on Wednesday May 18, 2022 @04:30AM (#31420446)
Do you know about .git/info/exclude? It only exists in your local git file so it isn’t shared with a remote repo and achieves this same purpose.
Re:Git ignores .gitignore with .gitignore in .gitignore by Hamuko on Wednesday May 18, 2022 @04:39AM (#31420496)
I also (mis)used .gitignore before I realised that there was an easy way to ignore stuff that I have locally without having to commit/ignore a .gitignore file.
Re:Git ignores .gitignore with .gitignore in .gitignore by rpigab on Wednesday May 18, 2022 @04:34AM (#31420466)
I didn't! Good to know, even if my way is really quick and simple to set up so I might continue doing the same. Thanks!
Re:Git ignores .gitignore with .gitignore in .gitignore by dfee on Wednesday May 18, 2022 @04:46AM (#31420536)
Not at a term, but would this prevent `git clean -fdx` from removing the dir? That’d be quite useful!
Re:Git ignores .gitignore with .gitignore in .gitignore by CGamesPlay on Wednesday May 18, 2022 @06:13AM (#31420975)
No, since -x means to “disregard standard ignore rules”, such as .gitignore and .git/info/exclude.

> Don’t use the standard ignore rules (see gitignore[5]), but still use the ignore rules given with -e options from the command line.

Re:Git ignores .gitignore with .gitignore in .gitignore by Deradon on Wednesday May 18, 2022 @05:36AM (#31420756)
Another comment already mentioned the `.git/info/exclude` directory. For completeness link to the online docs: https://git-scm.com/docs/gitignore

git will take 3 files into consideration for "ignoring" files:

> $XDG_CONFIG_HOME/git/ignore, $GIT_DIR/info/exclude, .gitignore

How I use them:

* ~/.gitignore: stuff I want to ignore everywhere (`/myNotes`, `.DS_STORE`, ...)

* <project>/.gitignore: stuff that should be ignore for this projects and shared with others

* <project>/.git/info/exclude; stuff for this project that only I want to ignore

** this is also super useful in combination with `git-bisect`

Re:Git ignores .gitignore with .gitignore in .gitignore by rollcat on Wednesday May 18, 2022 @06:19AM (#31421016)
This is my strategy for dotfiles. My home directory has a .gitignore with "*" in it. I will "git add -f" any files I want tracked; git is extremely efficient at ignoring the rest. It doesn't require any frameworks, symlinks, installation scripts, elaborate tutorials/manpages, or any other voodoo.

To move in to a new machine - unfortunately you can't git clone into a non-empty directory, but the commands to work around that are simple enough to remember.

https://github.com/rollcat/dotfiles

Re:Git ignores .gitignore with .gitignore in .gitignore by JoshTriplett on Wednesday May 18, 2022 @06:23AM (#31421041)
I prefer to list individual directories and files in my ~/.gitignore so that I see when new files show up and I can decide whether to ignore them, commit them, or prevent them from getting generated.
Re:Git ignores .gitignore with .gitignore in .gitignore by rollcat on Wednesday May 18, 2022 @06:55AM (#31421237)
It tends to blow up "git status" if some random new piece of software (or random me) makes a random new subfolder, full of random things. You can override .gitignore for specific subfolders like .config, .emacs.d, etc.
Re:Git ignores .gitignore with .gitignore in .gitignore by burntsushi on Wednesday May 18, 2022 @10:20AM (#31423115)
That's what I used to do, but I switched to Josh's strategy a couple years ago.[1] It doesn't "blow up" git-status. If some new piece of software creates a new directory with a bunch of random stuff in it, git-status will just show you the directory since it is is untracked, and not everything in it.

[1]: https://github.com/BurntSushi/dotfiles/blob/965383e6eeb0bad4...

Re:Git ignores .gitignore with .gitignore in .gitignore by Robin_Message on Wednesday May 18, 2022 @09:08AM (#31422301)
.git/info/exclude is a local .gitignore file which is never committed which you can also use for this kind of purpose.
Re:Git ignores .gitignore with .gitignore in .gitignore by alex_smart on Wednesday May 18, 2022 @04:53AM (#31420571)
I mean this is only a problem if your commit work flow is "git add . && git commit".

A bad habit, in my opinion.

Re:Git ignores .gitignore with .gitignore in .gitignore by sph on Wednesday May 18, 2022 @11:40AM (#31424126)
Disagree. How is that a bad habit? My workflow is "git status" to check what I've changed, "git add --all" and then "git commit".

"git status" needs to be clean. I don't want to see any untracked temporary files. If it's untracked either it needs to be ignored or it's a new source file to add to the index.

Keeping untracked files lying around not gitignored is a recipe for one day committing one by mistake, or conversely, that some of them are source files you've forgot to commit. I've seen both things from junior developers, that do not know of .gitignore.

Re:Git ignores .gitignore with .gitignore in .gitignore by alex_smart on Wednesday May 18, 2022 @03:00PM (#31426372)
>"git status" needs to be clean. I don't want to see any untracked temporary files.

Why do you not want to see any untracked files? What harm does it cause? What is the problem that you are trying to solve?

> If it's untracked either it needs to be ignored or it's a new source file to add to the index.

Or it is a file that stores your notes or experiments that don't necessarily belong in a branch, do not want to include in your next commit, but you also don't want to be invisible to ".gitignore" aware tools - and increasingly many modern tools are (vscode, ripgrep, emacs's projectile to name a few).

>Keeping untracked files lying around not gitignored is a recipe for one day committing one by mistake, or conversely, that some of them are source files you've forgot to commit.

Neither of those are a factor if you consciously check what you are committing using "git status" and "git diff --cached".

This is the habit you want to inculcate in your junior developers, that they should consciously think about the commit they are sending for code review, not that they should meticulously manage and be completely dependent on .gitignore (and i presume you also mean .git/info/exclude - because of course they would also have local files that they don't want to commit but are not worthy of being put into the repo's .gitignore).

Re:Git ignores .gitignore with .gitignore in .gitignore by ekimekim on Wednesday May 18, 2022 @06:43AM (#31421136)
There is value in "making a decision" for each untracked file, of whether to explicitly add it or ignore it. This combines well with things like a PS1 that indicates if you have any unclean state (including both changes and untracked files). Every single time I find myself with an untracked file, I can either add it because I want it tracked, put it in .gitignore if it's something generated that I want my whole team to ignore, or put it in .git/info/exclude if it's something I've done locally that doesn't fit either of the above.
Re:Git ignores .gitignore with .gitignore in .gitignore by alex_smart on Wednesday May 18, 2022 @09:57AM (#31422834)
>There is value in "making a decision" for each untracked file, of whether to explicitly add it or ignore it.

I would argue that you should decide between explicitly adding it or ignoring it, or deliberately doing neither.

>This combines well with things like a PS1 that indicates if you have any unclean state (including both changes and untracked files).

If you intend to keep untracked files in your directory, choose a PS1 that does not bother you about untracked files.

You are losing important information from git status when you exclude untracked files that you are actually working on and not just some random junk your ide generated. What if you look at the git status and conclude that there are no unchanged files worth tracking and then with that false sense of safety decide to run 'git clean -fdx'? You would lose those files permanently!

I honestly don't understand why the presence of untracked files in your git status is such a bother to you!? Like how exactly does it hurt?

Re:Git ignores .gitignore with .gitignore in .gitignore by Hackbraten on Wednesday May 18, 2022 @01:31PM (#31425394)
Cognitive clutter. Some people don’t care but it distracts me to no end. I want `git status` to tell me things that matter.

I certainly don’t want a meaningful code change sandwiched between an open editor swap file and some for-my-eyes-only temporary design scratch pad.

> then with that false sense of safety decide to run 'git clean -fdx'? You would lose those files permanently!

Correct, and that’s one of the reasons why the `-f` switch might be a poor fit. I use `-i` instead.

Re:Git ignores .gitignore with .gitignore in .gitignore by alex_smart on Wednesday May 18, 2022 @03:02PM (#31426384)
>I certainly don’t want a meaningful code change sandwiched between an open editor swap file

We are specifically not talking about the junk files created by editors and ides here.

We are talking about things like notes and exploratory code that you have written that you have no intention of committing, at least not right away. Why wouldn't you want to see them in your `git status`?

Another problem with putting such files in gitignore is that those files will become invisible to an increasingly large number of tools (vscode, ag aka silversearcher, ripgrep, emacs's projectile to name a few) that rely on gitignore to filter out unwanted files. So now, as far as these tools are concerned you have put your notes and experiments in the same category of files as editor junk and build artifacts. You either search them all or none at all.

Re:Git ignores .gitignore with .gitignore in .gitignore by Hackbraten on Wednesday May 18, 2022 @03:17PM (#31426551)
> Why wouldn't you want to see them in your `git status`?

I tend to function poorly around cognitive clutter. It distracts me from the important stuff: the files I’ve decided to put under version control. YMMV.

> will become invisible to an increasingly large number of tools (vscode, ag aka silversearcher, ripgrep, emacs's projectile to name a few)

That doesn’t really seem to be the case with VS Code. Ignored files appear grey but they’re still showing up for me.

Re:Git ignores .gitignore with .gitignore in .gitignore by alex_smart on Wednesday May 18, 2022 @11:41PM (#31430430)
>Ignored files appear grey but they’re still showing up for me.

They show up greyed out in the explorer yes, but they won't appear when you navigate with "Go to File" (ctrl+p) and they won't be searched through with "Search" (ctrl+shift+f).

Re:Git ignores .gitignore with .gitignore in .gitignore by Hackbraten on Friday May 20, 2022 @07:23AM (#31445886)
Good point!
Re:Git ignores .gitignore with .gitignore in .gitignore by TowerTall on Wednesday May 18, 2022 @04:59AM (#31420593)
This is what I do. Is there a "better" habit?
Re:Git ignores .gitignore with .gitignore in .gitignore by muhbaasu on Wednesday May 18, 2022 @05:06AM (#31420618)
Try `git add --patch` (or just `-p`). git will go through each change and you can decide if you want to stage it. You can even stage individual changes in a file.

This doesn't cover new files though. For those you can use `git add $filename` or even globs with `git add src/some/dir/*.$extension`.

Re:Git ignores .gitignore with .gitignore in .gitignore by fgeiger on Wednesday May 18, 2022 @05:27AM (#31420713)
For new files I use `git add -N` (if memory serves right; I am on mobile) to mark them as "I want this file to be included in `git add -p`"

Edit: The flag is -N or --intent-to-add

Re:Git ignores .gitignore with .gitignore in .gitignore by j16sdiz on Wednesday May 18, 2022 @11:24AM (#31423940)
You can use `git add -i` to pick files to add interactivelly
Re:Git ignores .gitignore with .gitignore in .gitignore by thefilmore on Wednesday May 18, 2022 @05:45AM (#31420807)
This is cool, wasn't aware of it.
Re:Git ignores .gitignore with .gitignore in .gitignore by nyuszika7h on Wednesday May 18, 2022 @06:30AM (#31421073)
I use `git add -p` regularly, and it's one of my major pet peeves that it doesn't include new files. I constantly forget to include those in commits because of that.
Re:Git ignores .gitignore with .gitignore in .gitignore by sgammon on Wednesday May 18, 2022 @05:12AM (#31420657)
came here to say this, git add -p is such a brilliant thing.

alias ga="clear ; git add -p" is an alias i always seem to keep

Re:Git ignores .gitignore with .gitignore in .gitignore by Merad on Wednesday May 18, 2022 @09:24AM (#31422463)
What type of workflow do you use where you regularly want to commit only some of your changes to a file? I honestly don't think I've ever had that need.
Re:Git ignores .gitignore with .gitignore in .gitignore by mdtusz on Wednesday May 18, 2022 @11:17AM (#31423867)
It's an extremely common and useful way to use git if you are making small and directed commits. This allows you to write code for some feature which includes multiple changes to a file, then make a few different commits with useful commit messages which describe and explain the changes - e.g. the first to include the definition of a new function and why/how it works, a second to modify some constant variable, and a final one to add calls to your new function at some callsite.

Working in this way creates more commits, but with them comes the context of the change, written in the commit message body as prose. This sadly isn't a common way to use git at lots of companies unfortunately, but it unlocks a ton of gits power and makes the commit log and tools like `git blame` and `git bisect` actually useful.

If you're making single commits that affect lots of files and descriptions like "Updated foo.py", you're missing out on a lot of the benefits that git provides.

Re:Git ignores .gitignore with .gitignore in .gitignore by gertlex on Wednesday May 18, 2022 @09:41AM (#31422635)
While some might be more rigorous about working on a commit at a time, a couple other helpful bits are:

- Cleaning up print() calls and similar debug - It's a first-pass review of your own changes; re-read docstrings/comments, and easily go right back to them and update them etc. The diff view is different from the coding view and you gain insights, etc.

This might apply moreso to my often script-oriented coding that does 20 new things, rather than e.g. unit-test backed "formal" coding that does a few specific things.

My own workflow isn't quite at the "commit often" level of frequency, but instead I'm simultaneously crafting several related but separately-reviewable commits in one branch for one PR.

Re:Git ignores .gitignore with .gitignore in .gitignore by thefilmore on Wednesday May 18, 2022 @05:41AM (#31420781)
`git add -u` for changes to existing files, and manually `git add` new files. `git diff --staged` to review what's staged. You can use `git gui` to do all this using a GUI.
Re:Git ignores .gitignore with .gitignore in .gitignore by martopix on Wednesday May 18, 2022 @05:06AM (#31420621)
Yes, the moment you construct a commit by 'git add' is the moment you review the changes you made. Very often you will find results or configuration files get added without you realising it; or you added a breakpoint() that you shouldn't commit, etc. Second, for meaningful commit messages, the commit should include changes that are related to each other. In summary `git add --all` or `git add .` should be used only after a careful inspection of `git status` or `git diff` showed you indeed need all changes, and that they belong to the same commit message.
Re:Git ignores .gitignore with .gitignore in .gitignore by throwawaylinux on Wednesday May 18, 2022 @06:18AM (#31421008)
Logical changes aren't necessarily partitioned by file. Very often I find they are not. I might make a feature or fix or cleanup that is say 10 related changes that each affect some subset of say half a dozen files, often even the same code multiple times.

Adding individual files can help partition out some changes, but it's very rare for me, it's much more often I have to go back and manually shuffle sub-file changes around if I didn't get the splits right the first time.

Re:Git ignores .gitignore with .gitignore in .gitignore by naavis on Wednesday May 18, 2022 @12:04PM (#31424424)
You could use `git add -p`

It lets you stage individual changes inside files instead of the whole file.

Re:Git ignores .gitignore with .gitignore in .gitignore by throwawaylinux on Wednesday May 18, 2022 @05:47PM (#31428075)
Right, I can do those things and sometimes do. Similarly to per-file I generally don't need to because I try to write and commit a logical change at a time.

I have no problem with people who do it some other way, it just seems odd to hear people proclaim a particular way to work with git is wrong, because it does not match how they work. Not sure if it's because they can't imagine any other way of working, or they just think all other ways are also wrong.

Re:Git ignores .gitignore with .gitignore in .gitignore by formerly_proven on Wednesday May 18, 2022 @05:35AM (#31420750)
Just use git-gui
Re:Git ignores .gitignore with .gitignore in .gitignore by alex_smart on Wednesday May 18, 2022 @05:11AM (#31420650)
Even if you don't want to go the whole "git add -p" route, at the very least:

1. Use "git add <filename>" manually for the files you want to add.

2. Do a "git status" and "git diff --cached" to review what you are about to commit before committing it.

Re:Git ignores .gitignore with .gitignore in .gitignore by Hamuko on Wednesday May 18, 2022 @05:00AM (#31420600)
I quite like my habit of adding stuff with `git add --patch` since it forces me to re-read stuff before I commit it. Graphical git clients like Fork or Sourcetree also allow to commit stuff in chunks.
Re:Git ignores .gitignore with .gitignore in .gitignore by kilroy123 on Wednesday May 18, 2022 @05:19AM (#31420685)
Agreed. This is the only way I ever add anything.
Re:Git ignores .gitignore with .gitignore in .gitignore by hibbelig on Wednesday May 18, 2022 @11:28AM (#31423991)
What's also useful is to set "commit.verbose" to true; then you get the diff in your editor when composing the commit message. This allows reviewing the diff and you can abort the commit if it's wrong.
Re:Git ignores .gitignore with .gitignore in .gitignore by ekimekim on Wednesday May 18, 2022 @06:45AM (#31421150)
To add to sibling comments which describe various uses of `git add`, I'll also recommend `git commit -a`, which adds all changes from tracked files (but unlike `git add .`, not untracked files) before committing.
Re:Git ignores .gitignore with .gitignore in .gitignore by bloopernova on Wednesday May 18, 2022 @07:29AM (#31421455)
I use fzf in multi-select mode

    fza = "!git ls-files -m -o --exclude-standard | fzf -m --print0 | xargs -0 git add"
That lets you interactively choose which files to stage.
Re:Git ignores .gitignore with .gitignore in .gitignore by hibbelig on Wednesday May 18, 2022 @11:26AM (#31423962)
I've started using lazygit and/or tig, these present a UI in the terminal and easily allow staging files. Lazygit also easily allows staging parts of a file; not quite sure about tig.
Re:Git ignores .gitignore with .gitignore in .gitignore by rjmunro on Wednesday May 18, 2022 @05:51AM (#31420846)
git gui

Add hunks, write the message, add more hunks, write more message. Once you are happy commit it, close the window. Don't try to use the CLI only because you are a power user who only uses the command line.

If you really can't use the gui (like your on a remote SSH session or something), the non-gui equivalent is git add -p, write your message in another editor, then git commit -F message.txt

Re:Git ignores .gitignore with .gitignore in .gitignore by zelphirkalt on Wednesday May 18, 2022 @06:22AM (#31421039)
Magit also makes this easy. One of the main features of magit, I think.
Re:Git ignores .gitignore with .gitignore in .gitignore by LinAGKar on Wednesday May 18, 2022 @08:57AM (#31422176)
It also keeps them from polluting git status
Re:Git ignores .gitignore with .gitignore in .gitignore by alex_smart on Wednesday May 18, 2022 @09:57AM (#31422836)
How is the git status "polluted" by reporting untracked files that you don't intend to commit?

If anything, I would say that such tricks make git status lie to you. What if you look at the git status and conclude that there are no unchanged files worth tracking and then with that false sense of safety decide to run 'git clean -fdx'? Sounds like an easy way to lose work.

Why is presence of untracked files in git status bothersome to anyone, especially when that is exactly what they are intentionally doing?

Re:Git ignores .gitignore with .gitignore in .gitignore by properdine on Wednesday May 18, 2022 @11:20AM (#31423905)
if you do a `git clean -f`, untracked files get deleted. Ignoring files that should stick around helps ensure that command can be used nicely. I've never used `git clean -fdx`, not sure why you would use the `-x` flag at all.

(but agreed if you use `-fdx` that doesn't work)

Re:Git ignores .gitignore with .gitignore in .gitignore by miskreant on Wednesday May 18, 2022 @09:36AM (#31422592)
You can also add lines to `.git/info/exclude` for permanent, local only ignores for a specific repo.
Re:Git ignores .gitignore with .gitignore in .gitignore by bhrgunatha on Wednesday May 18, 2022 @05:18AM (#31420681)
Thanks for sharing that idea. I'd simply never thought to do this and I'm adopting this in future.

The main drawback is something I do from time-to-time which is nuking and re-creating directories.

Re:Git ignores .gitignore with .gitignore in .gitignore by pcthrowaway on Wednesday May 18, 2022 @04:50AM (#31420557)
I'm in the habit of just adding these things directly to .gitignore for repos which I'm a core contributor to.

Things like:

    drafts/
    backup/
    *.bak
    ignored/
etc.

I don't really see the downside to just adding them to the tracked gitignore. If other people have a different convention and want to add these files/paths for some reason, it's easily discoverable to them why the files can't be added, and then we can have a discussion about what naming conventions we want.

Re:Git ignores .gitignore with .gitignore in .gitignore by AndrewThrowaway on Wednesday May 18, 2022 @04:58AM (#31420590)
The only problem I can see it "leaking" some information?

"I see this guy has 'passwords/'" on his local machine, let's somehow sneakily merge new .gitignore to make them available publicly.

Re:Git ignores .gitignore with .gitignore in .gitignore by asddubs on Wednesday May 18, 2022 @05:31AM (#31420735)
sure, if "this guy" does "git add '*'" and neither reviews the commit, nor even does git status to see a file list of it and just pushes it straight to remote. if that's happening i think your repo might have other problems though
Re:Git ignores .gitignore with .gitignore in .gitignore by pcthrowaway on Wednesday May 18, 2022 @11:06AM (#31423718)
I mean this doesn't really leak anything; passwords are usually stored in `.env` files anyway
Re:Git ignores .gitignore with .gitignore in .gitignore by naavis on Wednesday May 18, 2022 @12:07PM (#31424453)
It's not exactly best practice to store passwords in version control.
Re:Git ignores .gitignore with .gitignore in .gitignore by pcthrowaway on Wednesday May 18, 2022 @12:35PM (#31424802)
yes I'm aware.. this is why .env should always be in .gitignore
Re:Git ignores .gitignore with .gitignore in .gitignore by jerrygoyal on Wednesday May 18, 2022 @06:19AM (#31421018)
> mkdir drafts && echo '' > ./drafts/.gitignore

thanks for the tip, is there a way to hide files at root level? I want to hide some .env. files

Re:Git ignores .gitignore with .gitignore in .gitignore by thayne on Wednesday May 18, 2022 @07:40PM (#31428952)
That's cool!

You can also put local gitignore rules in .git/info/exclude , but i have a hard time remembering that exact path for some reason.

Re:Git ignores .gitignore with .gitignore in .gitignore by michaelsalim on Wednesday May 18, 2022 @06:51AM (#31421199)
This is awesome! Will probably use this at some point. Thanks for sharing.
Re:Git ignores .gitignore with .gitignore in .gitignore by AndrewThrowaway on Wednesday May 18, 2022 @04:59AM (#31420595)
I think this is quite genius, never thought about it before.
Re:Git ignores .gitignore with .gitignore in .gitignore by frays on Wednesday May 18, 2022 @05:54AM (#31420867)
This is a fantastic tip, thanks!
Re:Git ignores .gitignore with .gitignore in .gitignore by molszanski on Wednesday May 18, 2022 @07:22AM (#31421402)
brilliant! Thank you!