0

So this is the situation: I'm using VS-Code and the integrated terminal, if that matters.

git clone foo

Alright good. Now I add a document and save it.

git add . 
git commit -m "COmment what i did"
git push origin master 

works like a charm


Now I'm working on a .md file
In said file i want to add pictures.
I want to refer to those like:

./Images/NameOfThePicture.jpg

Using the integrated Terminal in VSC I used:

mkdir Images

So now there is ./src/Documentation/Images
Great!


But when I now do

git add ./Images
git commit -m "foo"
git push origin master

The ./Images directory simply isn't there.


So what I'm looking for is something like

git add ./Images
git commit -m "foo"
git push origin master

IT CAN'T BE THAT HARD, CAN IT?!


I did google a ton of stuff, but simply didn't find an answer I understood right off the bat.

Your help would be greatly appreciated!

Sam
  • 53
  • 1
  • 3

2 Answers2

0

There is no way to add a folder to git, as a folder doesn't have a diff. If you add files inside the folder, then the folder will be created when the repo is checked out.

Matthieu Brucher
  • 21,634
  • 7
  • 38
  • 62
  • Just to add to Matthieu's answer, git does not track directories. period. If a directory is empty, to git, it's as if it didn't exist at all. The easiest thing you can do is add a README file so that you explain what's going on in there and so the directory will magically show up. – eftshift0 Oct 04 '18 at 15:30
0

Since you're going to add things into the direcory, all you need to do is add the file within that directory:

git add ./Images/NameOfThePicture.jpg
git commit -m "Write a meaningful commit message."
git push origin master

As Matthieu Brucher said above, a blank folder doesn't have a diff, so it's difficult to add one, and in this case it's not necessary. If you do write an application that requires a blank folder to exist, there are workarounds, but most of them preclude you from then having anything in that folder.

aphoenix
  • 51
  • 4