0

Simply I have a git repository. And then directly on the server I just created images directory like this:

enter image description here

Now I push the changes from my local repository (there is no images directory), and images disappears. Why?

The question is:

What to do to tell git to not to do anything with images directory?

Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
  • I don't understand exactly what you are trying to do. If you don't want to include something in a commit, don't `git add` it. If it's not in a commit, it consequently doesn't "overwrite" anything if you `git push`. – mkrieger1 Jul 24 '19 at 08:24
  • If the `images` directory is present in the upstream and not in your repository (and the upstream `HEAD` is a parent to your local `HEAD`), then the `images` directory was deleted sometime between those two commits and this deletion is applied to upstream. – Simon Doppler Jul 24 '19 at 08:33
  • To find out which commit did delete the `images` directory, try `git log "images/*"` (the quotes are required for the wildcard to be passed to git) – Simon Doppler Jul 24 '19 at 08:36

2 Answers2

0

Add the directory contents to a .gitignore file.

Either

images/*

in the project root or

*
!.gitignore

in the images directory.

Calum Halpin
  • 1,945
  • 1
  • 10
  • 20
0

Git doesn't push files, Git pushes commits. (Commits contain files: each commit has a full snapshot of all the files.) The server that gets new commits then has to decide how it wants to deploy these new commits. That part is up to the server, not up to you doing the git push.

... And then directly on the server I just created images directory ...

If—if—the server deploys a new commit by completely removing the previous deployment and then completely installing the new commit, then your images directory gets completely removed, and replaced with nothing.

If the server deploys a new commit in some other manner, something else happens to the images directory you created directly on the server.

This is not a function of Git, which is not a deployment system. This is a function of whatever someone controlling the receiving Git on the server, programmed the server to do upon receiving new commits. Find out who that "someone" is; find out what they did; find out what you should to do update it to behave whichever way you want it to.

torek
  • 448,244
  • 59
  • 642
  • 775