I know there is a lot of questions like this, but no one solved my problem. I want something very simple - ignore all files and folders under specific folder except one file. This is what I try:
#Ignore
public/typings/*
#Allow
!public/typings/browser/ambient/jquery/jquery.d.ts
...but the file is still ignored.
Any suggestions?
It seems ! only works if the file is in the same folder. A possible workaround would be to nest the same statement till you get to your final file. A bit messy, but it works.
public/typings/*
!public/typings/browser
public/typings/browser/*
!public/typings/browser/ambient
public/typings/browser/ambient/*
!public/typings/browser/ambient/jquery
public/typings/browser/ambient/jquery/*
!public/typings/browser/ambient/jquery/jquery.d.ts
If the file was added in a previous commit before you put it in git ignore, it's possible your .gitignore is not working. I had the same problem few days ago. I solved the problem thanks to this post:
Post int randallkent
I hope this helps you
EDIT:
solution was found here: gitignore directory exception not working
I've been struggling a lot with this subject, let me share a procedure that worked for me:
1) Add the top level folder "abc/" to your .gitignore
2) Let's say that in "abc/" you have also "def/" and "jkl/" folders. If you want to keep the contents of "jkl/" you can just do:
git add -f jkl/*.php
Ok! Now everything inside "jkl/" with .php extension will be tracked by git, even in the next commits, without any headaches!
I've found this to be the right solution for my case, because I was really going insane trying to understand how gitignore does scan files and directories.
Related
I'm trying to copy several files with changing filenames. It seems very easy but I can't seem to work out how to do it without actually listing out the filenames in their entirety. The first few letters of the filenames correspond to the subject names which I'm looping through one by one. In each folder, there are 2 files, one is something like this subj1_load1_vs_load2.img, one is subj1_load1_vs_load2.hdr. I want both of them copied. Below is what I have:
subj={'subj1','subj2','subj3','subj4','subj5'}
for i=1:length(subj)
source=fullfile(filedir,subj{i},sprintf('^%s_.*\.*',subj{i})); % this doesn't seem to work
destination=fullfile(destdir,subj{i});
copyfile(source,destination);
end
I've also tried:
source=dir([filedir subj{i} strcat(subj{i},'*')]);
This appears to needlessly complicate since I will need to deal with .name. But perhaps I don't know how to use this well.
Anyway, the problem is with source as I'm trying to find the files i want to copy.
I'd appreciate any suggestions.
Below is Daniel's answer (which solved the issue for me)
source=fullfile(filedir,subj{i},strcat(subj{i},'*'))
I want Git to ignore a file named .wh..wh.aufs in the repo's root directory, because it was generated by my local file system (AUFS). But it doesn't help to place the pattern *.aufs in my ~/.config/git/ignore file, because the repo's root directory also has a .gitignore file with the negation pattern !.*.
Apparently the developers I cloned from want to force-track all files beginning with a dot. I still hope to share changes with them, and don't want to disrupt their arrangements. Without modifying their negation pattern, what's the best way to tell git to ignore my .wh..wh.aufs file?
I read the man page. The precedence policy seems to be working against me, unless there's something reliable I could do on the command line.
Check out the third technique here, maybe?
https://help.github.com/articles/ignoring-files
Adding the rule to .git/info/exclude might work for you.
I'm in the process of building a Lemonstand site, which I'm managing via git. As such, I'm using the following .gitignore rules:
# Lemonstand
.htaccess
php.ini
boot.php
index.php
install.php
/config/*
/controllers/*
/init/*
/logs/*
/phproad/*
/temp/*
/uploaded/*
/installer_files/*
/modules/backend/*
/modules/blog/*
/modules/cms/*
/modules/core/*
/modules/session/*
/modules/shop/*
/modules/system/*
/modules/users/*
# add content_*.php if you don't want erase client changes to content
/modules/gallery/*
/modules/lddevel/*
/modules/tweak/*
(The top block I got from github, with the second block being some additional rules I added myself to avoid issues with Lemonstands updating system).
My problem is that I'm adding a custom invoice to Lemonstand, which (to cut a long story short) requires the addition of a folder and some files within /modules/shop/invoice_templates/, which I've named cm_standard.
Because this is extra to the default Lemonstand, I want to get this tracked with git, so I'm trying to use the following rule to the bottom of my gitignore file:
!/modules/shop/invoice_templates/cm_standard/*
But when I do a git add -A, it isn't picking up the files within that directory. Even if I do a git add modules/shop/invoice_templates/cm_standard/* it tells me:
The following paths are ignored by one of your .gitignore files:
modules/shop/invoice_templates
Use -f if you really want to add them.
fatal: no files added
Which further suggests I've not written the rule correctly - can anyone help? Thank you.
Ignore patterns with fewer path segments can take precedence over patterns with more path segments, so in your case /modules/shop/* is taking precedence over !/modules/shop/invoice_templates/cm_standard/*, effectively pruning the whole of /modules/shop/invoice_templates/ from the directory traversal even before it looks at the contents of !/modules/shop/invoice_templates/cm_standard. Having said that, ordering can matter too, and when it does, somewhat counter-intuitively later rules within a file take precedence over earlier ones.
This question is very similar to How do gitignore exclusion rules actually work? so I suggest you read that. Also you may find the check-ignore subcommand useful when debugging rules - I added it to git over the last few months and it just appeared in version 1.8.2 which was released a few days ago.
I have several files in a GridFS Document Store and what I'd like to do is to pipe this data into a zip file via stdin in NodeJS. So that I will end up with a zip file containing all these files.
Now my question is how can I give the files a valid filename inside of the zip file. I think I need to emulate/fake a file header containing the filename?
Any help is appreciated!
Thanks
I had problems when writing zip files with Node.js not long ago. I ended up doing something similar to what is described in Zip archives in node.js
I can't help you directly with your problem, but at least I hope I can point out some things:
Don't try to use node-archive. Even if the description says it allows to create zip files, the moment I read the source code (since documentation is unexistant) I realized that's just a lie. It only exposes methods for reading.
Using zip by spawning a process, like recommended on the provided link, seems to be the best way. Something that would work is copying the files to a local folder with whatever name you desire and then calling the zip command, just to delete the files afterwards.
The other option, which seems ok, is to use zipper (https://github.com/rubenv/zipper, although better just use npm). The reason I'm not really wishing to use it is because there's not that much flexibility, it seems to have been done in a day and it hasn't been modified since the first commit, so I'm not sure it will receive maintenance (sure, you could just fork it...).
I swear the day I have an entire free weekend with no work I will write a freaking module that does this as complete as possible. It's silly that there isn't and it shouldn't be that much struggle. blablablarant.
Edit:
Not sure if it was there before, but now I've been using the node-compress module (also using gzippo). It works fine.
I have used mercurial for some time now and never had any problems using hgignore.
Now I have created a new project using eclipse, which added a .metadata directory.
I seem to be unable to ignore the .metadata.
nils#yavin $ hg status
? .metadata/.mylyn/repositories.xml.zip
? .metadata/.plugins/org.eclipse.core.resources/.history/37/509db4063df7001f14dbbfe704ff2c4e
...
My .hgignore looks like this:
syntax: regexp
/\.metadata/.*
\.metadata/.*
glob:.metadata/*
glob:.metadata/.mylyn/repositories.xml.zip
As you can see, I tried some things... I even tried adding one file directly, but it did not work.
Is there any magic involved when dealing with dot-directories? Or am I simply stupid today?
Just remove everything and leave:
glob:.metadata/*
The first line syntax:regexp in your .hgignore is making hg treat all subsequent lines as regex, including the one with glob:.metadata/*