Remote-pairing / Soft

How Git may outwit you and how you may outwit the Git

Have you ever experienced the situation when you do ask your machine to do action ‘A’ and it does ‘B’? I bet everyone had. I personally had such today – let me share what I learned.

A computer always performs what you ask it to do.

Nothing more, nothing less. When you delete the files without confirmation (Shift + Del), they’ll be removed without confirmation – no, no backup. When you build your code, it won’t do the clean up before. You asked for build – not the rebuild. It performs exactly what you asked for. Computer never guesses 😉

And it punched me today. Again.

.gitignore

Git (and not only Git) has a lovely concept of ignoring specific files/folders you don’t want to track. The list of rejected files is built by yourself, unless you get the generated one – from GitHub for example.

In my RemotePairing app, for debug purposes, I added Debug controller to list all calendar events I have in the database. Here’s the effect.

Implementation has worked, I’m about to push it to remote and… Debug files are not displayed in git status. Gitignore filters them out – I thought.

But when I reached the file in Notepad++ and pressed Ctrl+F with ‘deb’ query – nothing was shown. No occurrences.

WTF?

Maybe global .gitignore?

No.

What then?

git-check-ignore

As it happens in the vast majority of circumstances, someone already had that problem. And Git since 2016 provides the great functionality of pointing which rule filters specific file/folder.

At first, I confirmed that file is cut by git ignore by command git status --ignored

git ignore

Then I could just call this command to check the rule behind this specific folder:

git check-ignore -v source/CodHap.RemotePairing/Views/Debug

Line 16 of my gitignore! [Dd]ebug!

That’s another way of regular expressions that may hurt programmers 😉

So! The rule was there, I just failed to find it. But! Thanks to that I learned this cool feature of git today.

Cheers!

 

 

Somewhat experienced programmer who tries to find intrinsic meaning in each act he does. Increasingly builds his courage to let his life be driven by passion. Currently giving blogging a whirl.

Leave a Reply

Your email address will not be published. Required fields are marked *