Tag: gitignore

gitignore everything except specific files

I’ve been reading on Stack Overflow about using gitignore to ignore everything except specific files. I’ve tried a bunch of different suggestions, but I can’t get it to work for me. Here’s what I’m trying to do: I want to exclude everything except one file in my main directory and a couple other files in […]

Ignore all the files in the root except for some particular files, directories

I supposed this to do the trick: * !/dir1/ !/dir2/ !/file1 !/file2 But to my surprise, it didn’t. It seems to work if I prepend a slash before the asterisk. But I don’t really understand why it doesn’t work before this change. Could anybody point out?

Limit depth of .gitignore

For various reasons, I have the entry in my .gitignore in the root of a project: *.c As I desire, this ignores all C files from being included. However, I really only want the C files to only be ignored in the root directory, and not all the sub-directories: foo.c bar.c folder/baz.c In the above […]

Ignore folder in stable, but not in devel branch

I have the following folder structure for my project src/ test_unit/ package1/ test_unit/ package2/ test_unit output/ In my devel branch all folders should be version controlled, but the master/stable branch should ignore and not merge test_unit/ and output/ folder. How can I achieve this? With .gitignore it won’t work because .gitignore will be merged between […]

Git is not using the contents of .gitignore

I’m working with Rails and added the directory tmp and the Gemfile to my .gitignore. But every time I change it, git status tells me, that it changed. On both machines. On my developer machine and on the server. Kind of annoying. Contents of .gitignore: .DS_Store data/export/*.csv tmp/* *.rbc *.sassc .sass-cache capybara-*.html .rspec /.bundle /vendor/bundle […]

A way to validate .gitignore file

Is there a way to validate a .gitignore file so you quickly find doubles paths or paths that don’t exist anymore? Normally when a project is small this isn’t really necessary but with lots of branches and mergings of .gitignore files this can come in hand.

Git: ignore files but not sub-directories in a directory

I have a project in which all development is done at some directory depth, and so I’m used to cd-ing to a second-level directory and write some temporary files there. The tree looks like this: repo .git/ project/ dev/ important_stuff/ more_stuff/ README prod/ important_stuff/ more_stuff/ README temp_1.txt test.cc I would like to git-ignore exactly files […]

Git clean inside ignored folders

I have a folder foo that is included in gitignore: – .gitignore (this contains ‘foo’) – foo * *** bar When I run git clean -f or git clean -f -x, this does not delete bar (bar is a normal file). Is there a way to tell git to clean inside ignored folders?

Can I ignore the global .gitignore?

My global .gitignore is generally great but for this one off project I don’t want the global rules applied. How can I remove the global .gitignore rules for this one freak repository?

How can I write a rule in gitignore to ignore all files except directories in some directory?

So lets say I have a directory structure like so uploads/ –dir1/ —-one.txt —-two.txt —-dir2/ ——one.txt ——two.txt I would like any directory and sub directories of uploads to be tracked but not any files in it with the exception of a dummy file because git doesn’t track directories. I would think something like this would […]

Git Baby is a git and github fan, let's start git clone.