26

There's a question asking how to make Git track empty folders. This answer suggested a way: creating a file called .gitkeep. It was posted in 2011. In the comments there was much debate whether this name was appropriate; in particular, a comment upvoted more than 200 times said it isn't.

Then, one month ago (that is 11 years later), an edit by another user changed the suggested name to .keep.

I strongly disagree with this edit (or at least with the name change; they also added a few more lines that I find good). This is an answer with 1041 upvotes and 35 downvotes, and I think the specific name that it proposes is key to that. I would restore the original proposal... And yet, I see the answer's author is still active, though not much (a couple of posts per year). And they were online after that edit, but they didn't object to it.

In my opinion there are so many votes, cast in so many years, that even if in the meanwhile the author has changed their mind, the original file name should be restored. But before doing it I'd like to hear what the community thinks.

8
  • 18
    Yea, that's nonstandard. I've always seen .gitkeep used. Besides, the edit invalidates most of the discussion below it... Edits are not meant to enforce one's opinion, so I'm reverting that rename. Also, .gitkeep is a name that actually has search results, should one want to figure out what it does.
    – Cerbrus
    Commented Oct 28, 2022 at 19:01
  • 6
    IMO, depends - was OP's decision to use .gitkeep really deliberate? Would changing to something else be against their preferences, or was it just something they happened to go with 11 years ago? If the latter, and if SMEs think it's an unambiguously unfortunate choice, I'd support editing the answer to: "Create an empty file that starts with a ., such as .keep or .gitkeep. This way, <...>" with a bit of elaboration, including the good points in the comments. Commented Oct 28, 2022 at 19:54
  • 2
    Now, if the precise filename used was the core of the answer's suggestion, it'd be another story (definitely keep it per OP's preferences) - but it doesn't look to be. Commented Oct 28, 2022 at 19:56
  • 1
    @CertainPerformance I think it was, if not the core, at least a substantial part of it. But after all this is why I'm asking... Commented Oct 28, 2022 at 20:04
  • You can always open with a comment and see if there is a response (within a few days or even weeks). Commented Oct 28, 2022 at 22:07
  • 1
    @Cerbrus: I've always seen .gitignore with two lines: * and !.gitignore (which happens to be the top answer)
    – Joshua
    Commented Oct 29, 2022 at 3:00
  • Whilst we are looking at edits to that answer is it actually true that "This will be a hidden file on most systems by default" - unclear to me why this would be the case? Commented Oct 29, 2022 at 11:13
  • 4
    @MartinSmith unix.stackexchange.com/a/88907 If the filename starts with . Commented Oct 30, 2022 at 0:48

3 Answers 3

23

If I came across such an edit in the review queue, I'd have rejected it with the choice "Clearly conflicts with author's intent". If you have an alternative way to accomplish the goal the asker wants, then you should post it as your own answer, not replace someone else's (highly upvoted) way with your own.

11

I think the edit does not conflict with the original author's intent:

In their original revision they wrote

I think you can try to use .gitkeep

(which is also the only thing they ever wrote). This wording does not give a strong impression that the name of the file matters, rather it sounds as if they have seen this somewhere and want to share it, but are not really sure how or if it works.

The edit rather conflicts with the intent of the author of revision 2, who changed the answer to

Create an empty file called .gitkeep in the directory, and add that.

which kept the filename but changed the meaning. In my opinion this wording is misleading, as it gives the impression that it is important that the file is specifically named .gitkeep.

So I think the edit in question had the right intention, with an edit message

Added an extra bit of explanation and change .gitkeep to .keep so as not to give the impression this is some git related special file.

I'm in favor of a revision as suggested by @CaptainPerformance in the comments:

"Create an empty file that starts with a ., such as .keep or .gitkeep. This way, <...>"

to make it clear that the specific name of the file is not important.

3
  • 3
    I agree with this - the name of the file is completely irrelevant to the tool - all git cares about is there is content of any type in the directory. The whole thing is a hack to enable something Git doesn't support in the first place, which is having an empty directory in the repository.
    – Dan Lowe
    Commented Oct 30, 2022 at 20:13
  • 1
    It seems somewhat dubious to argue anything based on the original author's intent. There was literally nothing left of the original answer but the name .gitkeep. Commented Oct 31, 2022 at 14:37
  • 1
    Regarding "also the only thing they ever wrote" - this must surely be one of the highest ratios of reputation given vs words written (on a post) Commented Oct 31, 2022 at 17:22
6

I think the OP's choice of .gitkeep is better than .keep because it makes it clear that the reason for the file's existence is something to do with git. It's also a much more searchable term when you're wondering why it's there. Hopefully before someone removes it they'll follow the principle of Chesterton's fence.

So for me the edit should be rejected not because it's against the original intent, but simply because it makes the answer worse.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .