TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Stop Using Git Ignore

14 点作者 eddiejaoude9 个月前

16 条评论

gwynforthewyn9 个月前
Being honest, I dislike the tone of this sort of clickbaity rephrasing of the article title. The actual title is &quot;You must use your Global Git Ignore!&quot; which is completely true; the nuanced observation from the article &quot;Using the git ignore feature is great but it has limitations, which is why I think this file is overused and often incorrectly&quot; is a worthwhile hook, and presented thoughtfully.<p>The title &quot;Stop Using Git Ignore&quot;, which the author of the blog post chose for this submission, doesn&#x27;t represent his actual article well, though it probably gets more upvotes on Hacker News. I wish he&#x27;d presented the article more accurately, as it&#x27;s a worthwhile observation that, for example, we probably have so many .DS_Store files and .vscode&#x2F;.idea directories that defining them once will save us some hassle.
评论 #41285023 未加载
nullindividual9 个月前
You&#x27;d still need a repository .gitignore, more-so if you&#x27;re not working in a professional development shop (i.e., SMB&#x2F;enterprise IT) or open source project.<p>There don&#x27;t seem to be any downsides to a long .gitignore. Who cares if it is 100 or 1000 lines?<p>Kind of pointless, in my view. I think a user-global .gitignore is fine to have to make sure you don&#x27;t make mistakes for net-new projects or projects where someone forgot to add your exclusions, but otherwise, you&#x27;re going to need both if you choose to use a user-global.
评论 #41285009 未加载
评论 #41284835 未加载
ghusto9 个月前
This is bad advice. The repo’s ignore file is there so that other people (without certain domain knowledge) don’t accidentally commit undesirable files, including directories containing sensitive information (which get generated by some tools like Terraform).<p>Use the repo’s ignore, not your own.
评论 #41285187 未加载
评论 #41285244 未加载
efilife9 个月前
Problems listed in the article:<p>&gt; Everyone uses different operating systems, IDEs and dev tools.<p>How is this related to .gitignore?<p>&gt; This list will only keep growing, it will never end<p>Where&#x27;s the problem? A random Facebook&#x27;s repo has its gitignore file weigh 2KB[0]. Is this a problem?<p>&gt; Is the “.gitignore” file competing with the “README.md” for the most updated file in the git repo? I hope not<p>Again, why is this a bad thing?<p>The author just wanted to rant about something but didn&#x27;t know about what<p>*[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;facebook&#x2F;facebook-ios-sdk&#x2F;blob&#x2F;main&#x2F;.gitignore">https:&#x2F;&#x2F;github.com&#x2F;facebook&#x2F;facebook-ios-sdk&#x2F;blob&#x2F;main&#x2F;.giti...</a>
评论 #41285263 未加载
wobblyasp9 个月前
I&#x27;d rather enforce it at the repo then hope and pray everyone updates their global configs.<p>Easy enough to catch but you&#x27;ll miss some. Literally no cost to adding it to repo config either
评论 #41285075 未加载
vegetablepotpie9 个月前
Using a user gitignore file works if you’re responsible for your development environment. This does not work for other developers who are not responsible for their development environment.<p>The first place to catch errant build files and artifacts from entering the repo database is the .gitignore file. The second place to catch them is the PR. The .gitignore prevents repetitive file adds from entering the PR.<p>What I don’t want to see in an enterprise environment is someone checking in a 100MB binary file that gets checked into dev because the team was busy and approved a PR hastily. What would be helpful is a git hook that checks the mime type of a file and decide if it should even by a type of file that should be checked into a project.
评论 #41285202 未加载
default-kramer9 个月前
&gt; As a maintainer, don’t fall into the trap of putting every possible exclusion into the repo’s git ignore. This really is a “sticky plaster” approach in my view. What we should try to do is up-skill and educate the community, so it benefits everyone in the long run.<p>Strong disagree. Please do continue trying to educate the community, but that&#x27;s no reason to take the guardrails off.
评论 #41285129 未加载
forrestthewoods9 个月前
Disagree.<p>Many projects may want to commit IDE files. Ignoring them globally is simply wrong.
评论 #41284976 未加载
评论 #41285042 未加载
htk9 个月前
Let&#x27;s hope that people who resort to clickbait titles never complain about dark patterns in software, because what they do is analogous, they&#x27;re tricking me to their advantage.
评论 #41285169 未加载
TrianguloY9 个月前
Just a quick mention to remind that .gitignore files can be placed in any folder&#x2F;subfolder inside a repository, and they will refer to folders inside itself only. The global .gitignore should be used for global rules and root folders, but if you have path with more than one folder on it, you may want to add it to a .gitignore inside that subfolder itself.<p>Almost mandatory for monorepos too!
评论 #41285935 未加载
kennu9 个月前
It would be very inconvenient to try to synchronize global gitignore settings to all my computers and development environments. When .gitignore files are part of the project, they are automatically distributed everywhere where they are needed.
评论 #41289915 未加载
hbogert9 个月前
not sure I agree with the article or not, just wanted to state there&#x27;s a third option: you can define your ignore rules per project but not necessarily share the, by putting the ignore rules in:<p><pre><code> .git&#x2F;info&#x2F;exclude</code></pre>
评论 #41285157 未加载
jmclnx9 个月前
&gt;I think most people are aware of the repo’s git ignore file<p>Not me, never heard of it.<p>I use .&#x2F;.git&#x2F;info&#x2F;exclude to bypass commits and pushes, that is good enough for me.<p>Quickly reading the title, I though it was about stop using git period, go to something else :)
评论 #41285182 未加载
yodon9 个月前
Everyone is free to pick a proverbial hill to die on.<p>Some focus on battles they are likely to win, others on battles they are bound to lose.
评论 #41285044 未加载
dvt9 个月前
This seems like a terrible idea.. imagine framework A that has a throwaway folder called &quot;.blah&quot;—now imagine framework B that has a very important configuration folder called &quot;.blah&quot;—so at best this would only cover IDE and OS stuff. But that stuff ends up being like what, 10 lines at most?
评论 #41285057 未加载
Lws8039 个月前
Ignoring .env files globally could prevent some mistakes.. :D
评论 #41285142 未加载