Search code examples
gitgit-pushgit-commit

GIT on push to a remote server exlude folders/files


Is there a way to exclude certain directories when using "git push remote_name".

For example I have this folder/file structure in the repository:

/applications/
/libs/
/themes/
/misc/
/index.php
/robots.txt
/sitemap.xml

when I am working locally I commit all the changes I do to any files/folders, but when I need to "push" everything out to the remote server repository I want to exclude certain files and folders, like the "/themes/" folder and robots.txt file

Summary: locally I "commit" everything but the moment I need to do a "git push" I want to be able to exclude folders and files.

I hope that makes sense.

Thanks


Solution

  • No, you can't do this with Git. In Git, each commit is treated as one atomic entity; you can't pick and choose parts of a particular commit to push.

    If you want to break up your repository, such that some things are only tracked locally, and some pushed to the server, you should use separate repositories for each part, possibly linked together using Git submodules.