News for hackers. Stuff that matters.
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.