Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a single .gitignore after git svn create-ignore

Tags:

git

svn

git-svn

I have imported SVN repository with Git using:

git svn clone --preserve-empty-dirs --stdlayout svn+ssh://... SVN.git

It did succeed in the end although on the way it did fail few times and I had to "restart" with

git svn fetch

Yet it seems in the end everything is fine. (Although now when writing I start to wonder whether I should have provided --preserve-empty-dirs in the additional fetches as well? EDIT: No, I should not. See my comment bellow.)

Then I wanted to create .gitignore and so I did with

git svn create-ignore

And this succeeded as well.

But the end result is less than satisfying. It did generate lots of .gitignore files in many folders. It seems that each time when SVN had a svn:ignore property Git created corresponding .gitignore file.

While I would like to have them merged into a single root .gitignore file. This is possible with git since its far more flexible with ignores allowing to ignore in sub-directories with wildcards (or without them). Any way I think it is possible to automatically transform those "sub-.gitignores" into a single one at the root.

And I would like to have that because "SVN people" would not be happy with me committing over twenty .gitignore files...

like image 656
Adam Badura Avatar asked Dec 03 '12 09:12

Adam Badura


People also ask

How add ignore to Gitignore?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.

Should .gitignore be ignored?

The . gitignore file's purpose is to prevent everyone who collaborates on a project from accidentally commiting some common files in a project, such as generated cache files. Therefore you should not ignore .


Video Answer


1 Answers

I found a solution. You have to use show-ignore instead of create-ignore and save the output to a file.

So after cloning the repository execute following command:

git svn show-ignore > .gitignore

from the repository root where you have the .git directory.

like image 63
Adam Badura Avatar answered Oct 05 '22 22:10

Adam Badura