{"thread":{"id":"60861","subject":"Query about gitignore","startedAt":"2024-02-06T20:27:00Z","lastAt":"2024-03-04T09:51:29Z","messageCount":3,"participants":["Divyaditya Singh","Patrick Steinhardt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"488091","messageId":"B7F364DA-27E7-4BDC-93EE-32E6430B6ACE@gmail.com","threadId":"60861","inReplyTo":null,"subject":"Query about gitignore","fromName":"Divyaditya Singh","fromEmail":"divyadityasnaruka@gmail.com","sentAt":"2024-02-06T20:26:34Z","receivedAt":"2024-02-06T20:27:00Z","isPatch":false,"sender":{"key":"divyadityasnaruka@gmail.com","avatar":null},"body":"Hello there, \n\nI hope you are having a wonderful day. \nI apologize if this is inappropriate but I wanted to ask is there a way that I can make my .gitignore such that it ignores the entire parent directory of a matching file.\n\nThank You\nDV"},{"id":"488118","messageId":"ZcMYiOxBA-N0NwWT@tanuki","threadId":"60861","inReplyTo":"B7F364DA-27E7-4BDC-93EE-32E6430B6ACE@gmail.com","subject":"Re: Query about gitignore","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-02-07T05:43:36Z","receivedAt":"2024-02-07T05:43:41Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi Divyaditya,\n\nOn Wed, Feb 07, 2024 at 01:56:34AM +0530, Divyaditya Singh wrote:\n> Hello there,\n> \n> I hope you are having a wonderful day.\n> \n> I apologize if this is inappropriate but I wanted to ask is there a\n> way that I can make my .gitignore such that it ignores the entire\n> parent directory of a matching file.\n\nNot inappropriate at all!\n\nRephrasing what you say, you basically want to ignore \"dir/\" if and only\nif \"dir/a\" exists and matches a specific pattern in your gitignore,\nright? If so, this is not something that you can currently achieve with\ngitignores.\n\nWould you mind maybe explaining your particular usecase a bit more? This\n_could_ help to find a different solution for you. But even if there is\nnone it might motivate others to think about possible ways to implement\nthis in Git if there is interest.\n\nPatrick\n"},{"id":"489855","messageId":"ZeWZmyEcCTZ_u_tq@tanuki","threadId":"60861","inReplyTo":"A0502A2F-970B-46F3-B216-E82B2258DF3A@gmail.com","subject":"Re: Query about gitignore","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-03-04T09:51:23Z","receivedAt":"2024-03-04T09:51:29Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nadding the Git mailing list back to Cc.\n\nOn Thu, Feb 22, 2024 at 06:10:18PM +0530, Divyaditya Singh wrote:\n> Hello there, I wish you a wonderful day. It’s been a while since I\n> have written to you. I was curious if you had any suggestions or ideas\n> for my particular need? \n> \n> Thank You\n> Divyaditya\n\nsorry for my late reply, but I've been in office only sporadically\nduring the last two weeks.\n\nMy original question for your actual usecase was written with the intent\nto trigger other answers on the mailing list from potentially-interested\nfolks. So kind of trying to gather ideas or alternative solutions from\nfolks other than myself. Well, that didn't quite work out :)\n\n> > On 07-Feb-2024, at 11:52 AM, Divyaditya Singh\n> > <divyadityasnaruka@gmail.com> wrote:\n> > \n> > Hello Patrick,\n> > \n> > Thank you so much for taking time to respond to my email.\n> > \n> > Yes, I basically want to ignore “dir/“ if and only if if “dir/a”\n> > exists to match the pattern in the gitignore. I am not great at\n> > explaining but I would try to explain my use case to the best of my\n> > abilities. \n\nOkay. That is not currently possible with gitignore patterns.\n\n> > Some Context: I am a undergrad student and I am trying to currently\n> > build my portfolio website and I have planned some interesting stuff\n> > for the same and to showcase my abilities and working to potential\n> > future employers I have made the repository public.\n> > \n> > Use Case: While I am working on it, I plan to write some blogs about\n> > some interesting projects that I have been building along side that\n> > I am passionate about for which I am using markdown files to\n> > generate blog posts. \n> > \n> > Now, I set up my Next.js project such as the server scans the\n> > “posts/“ directory which will contain all my posts. Each post is a\n> > directory with the post slug as the directory’s name and each\n> > directory contains the structure for my post with index.md as the\n> > post text and along with other files related to the post. Now, I\n> > don’t want to upload unfinished blogs to the github and want the\n> > ability to work on different blogs simultaneously with the changes\n> > reflecting on the local device while working on the portfolio\n> > website itself. \n> > \n> > So, in my original approach I thought it would be really simple it I\n> > could just name it as “index.draft.md” and the entire post it not\n> > saved to git, instead of creating branches or work trees or creating\n> > an gitignored directory to store all incomplete posts and moving\n> > directories all the time. \n\nWell, my first thought regarding your usecase is \"branches\". They seem\nto fit the bill quite nicely: you have separate tracks of unfinished\nwork which you don't yet want to be part of your main branch. So if\nevery blog post lived on its own branch where you refine it until you\nare happy with it, then you can merge them into the main branch once\ndone.\n\nThe huge downside of gitignore is that those not-yet-finished blog posts\nwould... well, be ignored. That is you cannot save intermediate state\nthat you have, you cannot see how those blog posts evolved over time,\nyou basically lose all that Git is designed to help you with.\n\nSo I'd really recommend to give them a second thought, but in any case\nyour mileage may vary.\n\n> > I apologise again if my approach or way of thinking is stupid and\n> > for bothering you with this long email.\n\nNo worries, neither your approach nor your way of thinking is stupid.\nEverybody will have different workflows, and what works best for one\nperson may not work at all for a different one.\n\nPatrick\n\n> > \n> > Thank You,\n> > Divyaditya Singh\n> > \n> > \n> >> On 07-Feb-2024, at 11:13 AM, Patrick Steinhardt <ps@pks.im> wrote:\n> >> \n> >> Hi Divyaditya,\n> >> \n> >> On Wed, Feb 07, 2024 at 01:56:34AM +0530, Divyaditya Singh wrote:\n> >>> Hello there,\n> >>> \n> >>> I hope you are having a wonderful day.\n> >>> \n> >>> I apologize if this is inappropriate but I wanted to ask is there a\n> >>> way that I can make my .gitignore such that it ignores the entire\n> >>> parent directory of a matching file.\n> >> \n> >> Not inappropriate at all!\n> >> \n> >> Rephrasing what you say, you basically want to ignore \"dir/\" if and only\n> >> if \"dir/a\" exists and matches a specific pattern in your gitignore,\n> >> right? If so, this is not something that you can currently achieve with\n> >> gitignores.\n> >> \n> >> Would you mind maybe explaining your particular usecase a bit more? This\n> >> _could_ help to find a different solution for you. But even if there is\n> >> none it might motivate others to think about possible ways to implement\n> >> this in Git if there is interest.\n> >> \n> >> Patrick\n"}]}