1

Seen as my project is reaching half a gigabyte of disk space I'd like to avoid uploading/downloading that. But I do need to keep my project group up-to-date with all the changes that are being made by everyone on the team.

So when I tried to make a .gitignore to ignore everything except my C# files it ignored everything instead of committing them.

It works for the .gitattributes and .gitignore, though.
Which I find weird.

#Ignore everything
/*

#Except the neccesary files.
!.gitattributes
!.gitignore
!*.cs
!/Assets/RFPSP/
!/Assets/RFPSP/Scripts/*
!/Assets/RFPSP/Scripts/*/*
!/Assets/RFPSP/Scripts/*/*/*

I know the location of the code files (referenced above to the folder: "Scripts" and folders within that.) but it doesn't seem to work. If at all possible I'd like to keep the folder structure intact too, so that I can initialize a git repo on my main folder and update the file(s) in their respective location(s).

I thought this was the way to do it. Am I horribly mistaken or am I doing something terribly wrong?

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
sxbrentxs
  • 93
  • 7

2 Answers2

2

Try the following .gitignore configuration. It should work for your case. The first two lines make the trick.

/**
!/**/
!.gitattributes
!.gitignore
!*.cs
!Assets/RFPSP/Scripts/**

Refer to my answer here for explanations.

Community
  • 1
  • 1
Landys
  • 7,169
  • 3
  • 25
  • 34
1

Since you wish to ignore folders you have to use ** instead of *

!*.cs
!Assets/RFPSP/
!Assets/RFPSP/Scripts/**

# those are already matched in the above previous line so you wont need them
!Assets/RFPSP/Scripts/**/**
!Assets/RFPSP/Scripts/**/**/**
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • `https://github.com/sxbrentxs/FPS-GLU/blob/master/.gitignore` I tried that, but it doesn't want to work. – sxbrentxs Apr 25 '16 at 00:42