When I build myproject with the command:

dpkg-deb -z8 -Zgzip --build myproject

It packs all files inside the package.

Is there a way to ignore some folders from being packed inside the deb-file?

If I could ignore the folder .git then I could use the git-repository folder directly for generating the debian package.


It is very unusual to use low level commands like dpkg-deb to build debian packages - this looks like a XY-problem.

Usually, you build Debian packages from their source by using high level commands like debuild which then calls dpkg-buildpackage and other tools like dpkg-source. The actual .deb files are created by calling special targets of ./debian/rules inside the package source.

Depending on the package versions, .git is then automatically ignored.


dpkg-deb will build your Debian packages according to the package scripts, so in order to exclude one or more directories you may use dh_install -X .git (adding any other directory on the same line) in your debian/rules script.

For a similar information check https://stackoverflow.com/questions/9451347/remove-svn-while-building-debian-packages

  • 1
    The answer is not correct, dpkg-deb checks an existing control file, but does not call any package scripts at all. It is a very low level tool to pack files into a .deb file. – jofel Jul 9 '14 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.