Ignore pushing directory, but still track in Git

Is there any way to ignore a directory when you push remotely? The catch is I don’t want to ignore it. I still want to track the directory, and have local commits and branches for it. Say, I’m working on a project that relies on a database. This project does not have transitional schema or anything. It is populated with data for testing. I have a symbolic link for MySQL’s folder/files (MyISAM MYD/MYI) to my local repository. I want the database and the commits in sync, but cannot push the database (or assets, etc). I tried a submodule, with no avail – the parent repo ignores the child submodule changes. How would I go about this? Example structure:

/repo/my-project <– git repo
/repo/my-project/src <– push commits related to this section to a remote repo that uses this as the root directory

/repo/my-project/mysql <– track these but don’t push them


  • Proper git remote tracking practice
  • Git: Is there a short way to setup a new branch to track a remote branch?
  • How do I get a remote tracking branch to stay up to date with remote origin in a bare Git repository?
  • My local git tracking branch isn't working properly. I need advice on how to set it up
  • tracking remote repository from another remote in git
  • git: setting a single tracking remote from a public repo
  • Tracking Newly added Remote Branches
  • git fetch vs. git fetch origin master have different effects on tracking branch
  • 3 Solutions collect form web for “Ignore pushing directory, but still track in Git”

    When you push a given branch, you push the commits on that branch. If those commits include the contents of a given directory, you will be pushing that content.

    Your two options are:

    • Keep that directory on a branch (or branches) which are never merged into the branches you push. You can still merge other changes into that branch freely, of course.

    • Keep that directory in a separate repository. The easiest approach would then be to symlink that directory to the real location of the repository, and ignore the path. (You can ignore it in .git/info/excludes to avoid even publishing that gitignore entry.) More detailed instructions:

      cd path/to/project
      # move the directory outside your project
      mv database-dir ..
      # add an ignored symlink to it
      echo "database-dir" >> .git/info/excludes
      ln -s ../database-dir database-dir
      # create a new repo in the directory to track it
      cd ../database-dir
      git init; git add .; git commit

    It’s possible to ignore files from inclusion to your repository by adding them to the .gitignore file — but I don’t think that’s what you want.

    Try this: http://book.git-scm.com/4_ignoring_files.html

    Why not track the database in a separate repository without a remote branch?

    (Note that if you never push remotely, you wont have a backup if your hard drive fails.)

    Git Baby is a git and github fan, let's start git clone.