16 ms·
Git ignores .gitignore with .gitignore in .gitignore
- catskul2 5y agoWhy on earth is there a picture of a school girl in the upper right of the page?! It feels creepy, and unprofessional. I've seen this sort of thing before and I really don't understand it. Can anyone explain this phenomenon?
- CRConrad 4y ago[EDIT:] See https://rubenerd.com/about/#mascot https://rubenerd.com/about/#mascot and https://rubenerd.com/anime-restore-my-blog/ https://rubenerd.com/anime-restore-my-blog/ . Looks like a typical harmless Anime nerd to me. [/EDIT] Not just any schoolgirl, but a schoolgirl drawn in "Manga"[1] or "Anime"[2] style, AFAICS. Lots of people are Manga and/or Anime fans, and many of those perhaps to such an extent that they feel it's a major part of their identity, so they want to show it some way. And a lot of those Japanese comics and animated films just happen to have young people of both sexes as their protagonists, so of course there will be schoolgirls in them. And much of that is, as I've understood it, "perfectly ordinary" comics and animations, like any "Young Adult" literature in Western culture; no more (explicitly) sexualised than Harry Potter or Star Wars. So not necessarily "creepy", in the sense of sexualising schoolgirls... But yeah, from what (little) I understand of Japanese popular culture, sexualising schoolgirls is a pretty big part of current more-or-less accepted Japanese social mores, which is reflected in Manga and Anime too; see the whole phenomenon of "Hentai".[3] And I suppose there's a whole lot of Manga and Anime that is just titillating -- not quite explicitly, but borderline sexualised. I have no idea about the proportions between the categories: I read quite a lot of Marvel and DC comics (and, ahem, some porn -- but those were wildly different things back then) in my youth, but that's so long ago that it was before the rise of Japanese popular culture phenomena in the West, so I've never been into any of that stuff. For all I know, the "creepy" stuff could be a majority of it; or it could be just a comparatively tiny fringe phenomenon. So, summing up: Not necessarily creepy, but certainly gives at least me vibes of "potentially rather creepy". But, in the absence of any proof to the contrary, I guess I'd go with the guidelines and assume the best. ___ [1]: https://en.m.wikipedia.org/wiki/Manga https://en.m.wikipedia.org/wiki/Manga [2]: https://en.m.wikipedia.org/wiki/Anime#Genres https://en.m.wikipedia.org/wiki/Anime#Genres [3]: https://en.m.wikipedia.org/wiki/Hentai https://en.m.wikipedia.org/wiki/Hentai (NSFW![4]) [4]: Well, depending.
- groffee 5y agoYo dawg, I heard you like .gitignore, so we put a .gitignore in your .gitignore so you can .gitignore while you .gitignore.
- neals 5y agoDid you know that Pimp My Ride first aired in 2004. That is 18 years ago. A whole generation of now growns ups don't know the show.
- sedeki 5y agoI'm old enough to remember the show Pimp My Ride, but I don't recall Xzibit ever having that "catchphrase" on it.
- semi-extrinsic 5y agoIt wasn't an exact catchphrase, but a common theme of the series was that they would figure out some non-car-related thing that the person liked, and work that into the car. Then Xzibit presenting the car to the person would be like, yo, we heard that you like fish, so we installed this 20 gallon fishtank in your trunk. Thus spawned the meme. Like the Bear Grylls thing, it's not like he drinks his own urine in every episode, yet it was enough to spawn a meme.
- pnt12 5y agoMaybe someone liked cars and he put a car inside their car!
- DocTomoe 5y agoI've seen reruns of that some three years ago. The new generation knows about the show, and shitty cars being made more shitty is timeless.
- _fat_santa 5y agoI miss that show. It was so over the top and encapsulated it's own era so well.
- netsharc 5y agoIt's following the instructions to not track changes of that file, if he was expecting it to follow instructions to "treat as if this file isn't a configuration", he's excpecting wrong.
- rpigab 5y agoThis 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.
- RupertWiser 5y agoDo 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.
- rpigab 5y agoI 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!
- Hamuko 5y agoI 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.
- dfee 5y agoNot at a term, but would this prevent `git clean -fdx` from removing the dir? That’d be quite useful!
- deleted 5y ago[deleted]
- CGamesPlay 5y agoNo, 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.
- quickthrower2 5y agoDoes what it says on the tin! Probably useful if you want a seperate dev-preferenced-specific gitignore in a subfolder. For example to ignore editor droppings for an editor that only you use.
- rplnt 5y agoSurprising? No. Under that same expectations untracked .gitignores wouldn't work either and we know that's not the case. But there are things that are both obvious once you know about them, but might not otherwise cross your mind. So this is definitely useful and informative.
- martopix 5y agoThere's a misunderstanding: "ignoring" means "not tracking as part of version control". But the author overloads the term "ignore" with "not look at it as a .gitignore configuration file".
- wazari972 5y agoexactly, > Therefore, we can see Git ignores .gitignore because its in .gitignore, which means it didn’t ignore .gitignore for instructions. > Is any of this informative, surprising, or useful? … Absolutely. it's interesting to notice, but nothing surprising. git isn't supposed to ignore it for instructions
- YPPH 5y agoI'm willing to assume this is not a misunderstanding at all. It's either satirical or pointing out an effect which at first blush might seem counterintuitive. I found it amusing.
- martopix 5y agoI would agree with you.
- acatton 5y agoThis is a recipe for disaster. Especially if somebody else commits a gitignore in your repository. If you want an untracked list of files to not track, use .git/info/exclude, it's literally made for this. This is not a hidden feature, it is documented https://git-scm.com/docs/gitignore https://git-scm.com/docs/gitignore
- rjmunro 5y agoIf someone else commits a .gitignore in your repository, .gitignore is in your repository and will stay there. .gitignore is only used in deciding if an untracked file should be added. It makes no difference to existing files.
- richardwhiuk 5y agoYou'll get a conflict when you try and pull I think.
- deleted 5y ago[deleted]
- acatton 5y agoIf you do `echo .gitignore > .gitignore` and then somebody elses commit a git ignore, and you pull from that repository, your local .gitignore will be silently overriden, and you might add untracked files if you have the bad habit of `git commit -a`. $ for repo in alice bob; git init $repo $ git init --bare shared $ cd bob $ touch foo $ git add foo $ git commit -m "Initial commit" $ git push ../shared $ cd ../alice $ git pull ../shared $ echo bar > .gitignore $ git add .gitignore $ git commit -m "Add gitignore" $ git push ../shared $ cd ../bob $ echo .gitignore > .gitignore $ git pull ../shared remote: Enumerating objects: 4, done. remote: Counting objects: 100% (4/4), done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), 272 bytes | 272.00 KiB/s, done. From ../shared * branch HEAD -> FETCH_HEAD Updating 343eb88..3701fae Fast-forward .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore $ cat .gitignore bar
- fbn79 5y agoI was ignoring it!
- shantnutiwari 5y agoIt's turtles all the way down :) I just found out (from @RupertWiser https://news.ycombinator.com/item?id=31420446 https://news.ycombinator.com/item?id=31420446) about the .git/info/exclude, I find that more interesting
- bumblebritches5 5y ago
- zmmmmm 5y agoIt's a good example of how subtle requirements can be and how unlikely it is you could get them right until people are actually using your software in real life.
- junon 5y agoAre you implying this is a bug?
- zmmmmm 5y agothe opposite : it's exactly how it should work, but how likely is it that someone sitting down to write requirements in advance would have managed to get this right? So many things obvious in hindsight are nearly impossible to anticipate up front.
- junon 5y agoI disagree, this is just a side effect of good software design. Understanding how git works at the lower level makes this an obvious behavior. There was no PM/PO that sat down and decided this is explicitly what should happen.
- tedk-42 5y agoGit also ignores things you add into the `.git` folder (where your git history lives). You can use that as a place to store things quickly rather than say, doing a stash.
- tiborsaas 5y agoThanks, I hate that I know this now.
- junon 5y agoDon't do this. It's a quick way to corrupt your repository.
- pnt12 5y agoWhen this happens, I usually create ./tmp/ and add it to .gitignore.
- junon 5y agoThis is also a bad decision because now you have to tip toe around the modified .gitignore.
- syncsynchalt 5y agoYou can add it to .git/info/exclude. That's a gitignore that's repo-local.
- junon 5y agoyep, that's the best solution.
- rjmunro 5y agogit couldn't take .gitignore into account when deciding to look at .gitignore, even if it wanted to, because it's not read .gitignore yet. It's like "Is 'No' the answer to this question?"
- TobTobXX 5y agoGit IS looking at it. It's just nod adding it or showing it in the status. There's a difference between reading/parsing and adding/committing.
- vrocmod 5y agoIt vaguely reminds me of https://en.m.wikipedia.org/wiki/Russell%27s_paradox https://en.m.wikipedia.org/wiki/Russell%27s_paradox
- deleted 5y ago[deleted]
- brainwipe 5y agoI'm delighted by this. I'm not entirely sure why but I am.
- rubenerd 5y agoThat made my morning, thanks :)
- sudhirj 5y agoLove it. Git obviously ignores the instructions on what to ignore that tell it to ignore instructions on what it ignore.
- anshargal 5y agoThe following .gitignore is my favorite way to commit an (almost) empty folder to git: # Ignore everything in this directory * # Except this file !.gitignore .gitignore can be present in any directory and there is a way to unignore a wildcard
- _fat_santa 5y agoI was looking at someone's dotfiles on Github a while back and they employed this method. Essentially they made their entire home directory a git repo but used gitignore to ignore everything but the dotfiles they wanted to backup. It was a pretty nifty setup
- ansible 5y agoI feel obligated to point out vcsh [1], which is likely already packaged for your operating system. [1] https://github.com/RichiH/vcsh https://github.com/RichiH/vcsh The main selling point is that you can set up various git repos for different things. I have one for SSH keys (and no, that does not get pushed anywhere except to my own private server), VIM, neovim, bash, and 'other' (for misc config files like .dir_colors, .gitconfig, etc.).
- account42 5y agoA nifty setup until you run a git command like `git clean -fx` somewhere under your home directory that you think is another git directory but isn't. Happy restore from backups time.
- joboyx 5y agoAnother option is to clone the dotfiles repo to your workspace. Then create symbolic links in your home directory. Like: ln -fs ~/workspace/dotfiles/vimrc ~/.vimrc
- einpoklum 5y agoHow much ignore would a git gitignore ignore if that gitignore was a git?
- raghavtoshniwal 5y agopip uninstall pip also works, I found out the hard way.
- danillonunes 5y agoHa! This is the tech savvy version of that gif where a old man drags the "my computer" icon to the trash and then see the computer disappearing in front of his eyes.
- bin_bash 5y agoThis is exactly how I would expect it to work. It's just the title that's confusing.
- gweinberg 5y agoYes. I interpreted the title to mean "If you put .gitnore in your.gitignore, the .gitignore stops working". And so I immediatly thought "that's wrong". Why would anyone thing you wouldn't be able to put .gitignore in your .gitignore?
- andrethegiant 5y agor/WordAvalanches
- seba_dos1 5y agoIs it actually surprising though? Doesn't seem to me, you quickly figure out in regular usage that it's not the committed content of this file that matters, and this is just a natural consequence.
- wheybags 5y agoSomething I've always wanted from gitignore: a way to ignore changes to a file that is already present in the repo. So, for example, I can commit a config file that should contain secure credentials with the credentials redacted, and then ignore it so the credentials don't accidentally get pushed from someone's working dir. For now what I do is ignore the config path and commit an "x.conf.example" file, but that is a bit more of a pain to use.
- coder543 5y agoI think the .conf.example approach is probably better, but the answer to your implied question is here: https://git-scm.com/docs/git-update-index https://git-scm.com/docs/git-update-index If you use --assume-unchanged on a file, then git will stop noticing changes at that point. I believe this only applies to your copy of the repo, though.
- joboyx 5y agoi'm using Intellij, so for scenarios like this I create a separate "changelist" with name "LOCAL-ONLY" and include passwords and any local config that only applies to me. That way I can clearly see that these changes don't get commited. You can also put line changes on the same file on different changelists. Changelists concept is native with P4, but not sure with git. Maybe that's why Intellij only have it coz they've implemented their own on top of git.
- chrisfinazzo 5y agoYep. https://en.wikipedia.org/wiki/Turtles_all_the_way_down https://en.wikipedia.org/wiki/Turtles_all_the_way_down
- account42 5y ago> Is any of this [...] surprising [...] … Absolutely. Not at all - .gitignore is for ignoring working tree files in git operations, essentially it specifies which files are not part of the repository. It is not for disabling config files and I don't think why anyone would expect that. Putting .git in .gitignore also does not make git think there is no repo because why would it?
- capitainenemo 5y agoKinda works w/ mercurial. $ hg init foo $ cd foo $ echo ".hgignore" > .hgignore $ hg st $ rm .hgignore $ touch .hgignore $ hg st ? .hgignore ... apart from the ignored folder. Mercurial can't do that.
- anderspitman 5y agoI've considered (overuse of) .gitignore an antipattern for several years now. I've been bitten too many times by it hiding the differences between my local repo and someone else's. With some projects that ignore build artifacts it's very difficult to know whether you've successfully performed a clean or not. I don't see a problem with having a dirty repo. It makes it clear how the state of my local directory is different from what's in source control. Isn't that the whole point? I'm sure I'm missing something, but so far I haven't missed .gitignore.
- darau1 5y agoIn my experience, people tend to `git commit -am "nonsense"` no matter how many times I tell them not to. .gitignore at least ensures they don't add too much nonsense to the repository.
- CGamesPlay 5y agoYou can easily use git status --ignored for those cases where you really want to see all the cruft you’ve accumulated. Or you can make an alias to mask status and add that flag, then use git status --ignored=no when you don’t want the behavior.
- hedora 5y agoIf it does, that's impressive. Someone should generalize their approach to solve the halting problem.
- mc4ndr3 5y agoWhat working at several engie roles teaches you about git: Don't expect people to know how to gitignore. Or submodule. Or tag. Or interactive rebase. Or squash. Or branch. But when you encounter a team that knows a thing or two, they git fascist and demand you re-enter the Jira ticket number three times in every commit message (in ALL CAPS).
- monsterofcookie 5y agoOnly proves that devs are susceptible to dad humor.
- rubenerd 5y agoHi, author here. Yes this was just a bit of silly/pointless fun, though people overanalysing it here is just as delightful.
- neycoda 5y agoGit has to read .gitignore to get the instruction to ignore .gitignore, but since it's already read .gitignore, it can't go back and ignore .gitignore.
- comrad 5y agoWell. It does what you told it to do, right?