views:

61

answers:

2

I am using git with capistrano.

I initialized my project inside my folder on my local machine as such:

git init

I then pushed the project the server directory I then called cap deploy The deploy works, except that it uploads the local .git folder structure, as well as my .gitignore and Capfile to a publicly accessible folder.

Here's my gitignore file:

.DS_Store
uploads/**/*
Capfile
.gitignore
.git/**/*

This doesn't seem to do the trick. Any help?

Thanks!


Edit: updated .gitignore file:

Changed deployment strategy to export:

set :deploy_via, :export

This works for ignoring the .git folder, but the contents of my .gitignore file seen below are still not taken into account

.DS_Store
includes/php/config.php
/uploads
Capfile
.git





EDIT 2 (Solution): Edit 1 in combination with the following did the trick. Files that were already added prior to being listed in the .gitignore file would constantly be uploaded. Say I had the following .gitignore file.

.DS_Store
includes/php/config.php

Then I ran the following commands:

git add .
git commit -a -m 'some commit'

Then I decided to add to my .gitignore file so it now looks like this:

.DS_Store
includes/php/config.php
Capfile

Then again, I ran:

git add .
git commit -a -m 'another commit'

Now I'd see that .DS_Store and includes/php/config.php have not been uploaded, but that the Capfile has... This is what happened to me in my original question. The reason: I think the .gitignore file is taken into account only when adding (i.e. git add .). If I already added files, then put them in the .gitignore file, they would have already been added to the project. I'd need to use the git rm command to remove them. I just started anew with a new .git repo and that solved the problem, but you don't have to - you can just remove whatever files you already added but now want to ignore with the git rm command.

I selected the answer that helped me get to this conclusion as the right one, though the complete solution was just detailed above.

+1  A: 

What is your deploy strategy?

Do you have Capistrano setup to exclude the .git file? if you are using set :deploy_via, :copy then make sure to add the following:

set :copy_exclude, [".git/*", ".svn/*", ".DS_Store"]

Otherwise use set :deploy_via, :export which should ignore your source control folders

http://www.capify.org/index.php/Understanding_Deployment_Strategies

Zaid Zawaideh
that worked for ignoring the .git folder, but my .gitignore file is still not taken into account. Please see edit
yuval
do you have `set :scm, :git` in your deploy?
Zaid Zawaideh
+1  A: 

Looking at a similar question, it appears you don't need the wild card selectors and can just have:

uploads/

You need to deploy via :git in Capistrano and do an export. It's essentially a git clone and then just deletes the .git directory afterwards.

Your problem isn't much to do with Cap really. Make sure your .gitignore file is working correctly.

The Pixel Developer