Thread (1 message) 1 message, 1 author, 2024-03-04

Re: Query about gitignore

From: Patrick Steinhardt <hidden>
Date: 2024-03-04 09:51:29

Hi,

adding the Git mailing list back to Cc.

On Thu, Feb 22, 2024 at 06:10:18PM +0530, Divyaditya Singh wrote:
Hello there, I wish you a wonderful day. It’s been a while since I
have written to you. I was curious if you had any suggestions or ideas
for my particular need? 

Thank You
Divyaditya
sorry for my late reply, but I've been in office only sporadically
during the last two weeks.

My original question for your actual usecase was written with the intent
to trigger other answers on the mailing list from potentially-interested
folks. So kind of trying to gather ideas or alternative solutions from
folks other than myself. Well, that didn't quite work out :)
quoted
On 07-Feb-2024, at 11:52 AM, Divyaditya Singh
[off-list ref] wrote:

Hello Patrick,

Thank you so much for taking time to respond to my email.

Yes, I basically want to ignore “dir/“ if and only if if “dir/a”
exists to match the pattern in the gitignore. I am not great at
explaining but I would try to explain my use case to the best of my
abilities. 
Okay. That is not currently possible with gitignore patterns.
quoted
Some Context: I am a undergrad student and I am trying to currently
build my portfolio website and I have planned some interesting stuff
for the same and to showcase my abilities and working to potential
future employers I have made the repository public.

Use Case: While I am working on it, I plan to write some blogs about
some interesting projects that I have been building along side that
I am passionate about for which I am using markdown files to
generate blog posts. 

Now, I set up my Next.js project such as the server scans the
“posts/“ directory which will contain all my posts. Each post is a
directory with the post slug as the directory’s name and each
directory contains the structure for my post with index.md as the
post text and along with other files related to the post. Now, I
don’t want to upload unfinished blogs to the github and want the
ability to work on different blogs simultaneously with the changes
reflecting on the local device while working on the portfolio
website itself. 

So, in my original approach I thought it would be really simple it I
could just name it as “index.draft.md” and the entire post it not
saved to git, instead of creating branches or work trees or creating
an gitignored directory to store all incomplete posts and moving
directories all the time. 
Well, my first thought regarding your usecase is "branches". They seem
to fit the bill quite nicely: you have separate tracks of unfinished
work which you don't yet want to be part of your main branch. So if
every blog post lived on its own branch where you refine it until you
are happy with it, then you can merge them into the main branch once
done.

The huge downside of gitignore is that those not-yet-finished blog posts
would... well, be ignored. That is you cannot save intermediate state
that you have, you cannot see how those blog posts evolved over time,
you basically lose all that Git is designed to help you with.

So I'd really recommend to give them a second thought, but in any case
your mileage may vary.
quoted
I apologise again if my approach or way of thinking is stupid and
for bothering you with this long email.
No worries, neither your approach nor your way of thinking is stupid.
Everybody will have different workflows, and what works best for one
person may not work at all for a different one.

Patrick
quoted
Thank You,
Divyaditya Singh

quoted
On 07-Feb-2024, at 11:13 AM, Patrick Steinhardt [off-list ref] wrote:

Hi Divyaditya,

On Wed, Feb 07, 2024 at 01:56:34AM +0530, Divyaditya Singh wrote:
quoted
Hello there,

I hope you are having a wonderful day.

I 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.
Not inappropriate at all!

Rephrasing what you say, you basically want to ignore "dir/" if and only
if "dir/a" exists and matches a specific pattern in your gitignore,
right? If so, this is not something that you can currently achieve with
gitignores.

Would you mind maybe explaining your particular usecase a bit more? This
_could_ help to find a different solution for you. But even if there is
none it might motivate others to think about possible ways to implement
this in Git if there is interest.

Patrick

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help