Blog

You are filtering on tag 'tutorial'. Remove Filters
RSS

.gitignore: permit only certain paths with negation

May 15th, 2014 (edited November 3rd, 2022)

Today I was trying to create a .gitignore file for a project that has to live in the same directory as a number of different folders. I wanted the git repo to only include folders that start with the string heroscape, while excluding any other folder.

The gitignore man pages point out that you can negate a pattern by putting a ! in front of it. I didn't notice at first that this does not ignore anything that does not match the pattern. Instead, it re-includes any previously ignored paths that match the negated pattern.

So to achieve what I wanted, I had to do the following, first ignoring all folders, then re-including folders that begin with "heroscape".

*/
!heroscape*/


Permalink

Keeping cmd windows open with /K

January 29th, 2014

I like using .BAT files to run common tasks like compiling Java code or starting my NodeJS server. It's very convenient to just execute a .BAT where you've already written out all the proper parameters rather than typing out an entire call every time you need it. This does cause a problem, though - if any of the programs that execute from the .BAT returns an error code, the command window will immediately close. This makes it impossible to debug those programs.

I tried adding the pause command at the end of each file, but to no avail - the command window exits immediately when a program returns an error and doesn't execute the rest of the file (which is responsible of it, admittedly).

The solution was to use a parameter to the cmd program itself:

cmd /K bat/mybat.bat

The /K parameter keeps the window open even if the .BAT stops executing. I simply copied all my .BATs to a subdirectory and created wrapper bats using this line.


Permalink


Previous Page
7 posts — page 2 of 2
Next Page