dodov
dodov

Reputation: 5844

Git - ignore directory when pulling, don't when pushing

I searched for an answer to this, but I just found other stuff related to .gitignore.

I have a demo folder in my repo for a demonstration of my package. When I push, I want it to be uploaded just because I want it stored and updated along with the package.

However, when someone clones the repo, I don't want them to have the demo, because they don't need it. They only need the files in lib to use the package.

What I tried

I tried adding demo to my .gitignore, git add . -f and then pushing. The demo was uploaded. However, when I git clone the repo in another folder, the demo files are still downloaded.

Upvotes: 2

Views: 720

Answers (2)

fulltimecoder
fulltimecoder

Reputation: 21

git commit what them (don't push), then git pull:

  1. git status to check what you have done.
  2. remove from list which files you will accept change after git pull
  3. then git add -A to makesure they're will not changed
  4. then git commit -m "your message", after that don't push
  5. finally git pull

Upvotes: 0

Vampire
Vampire

Reputation: 38724

This is not possible. Either demo is part of the repo or not. .gitignore is only effective on untracked files. As soon as a file is tracked, .gitignore is not taken into consideration.

Upvotes: 2

Related Questions