Git: I can add a directory, but at the time of commit I get "do nothing",

I am trying to add two directories to a git repository. I can add them in order, but when I try to β€œcommit”, I get β€œnot commit anything”. I follow the add-> commit-> push command, but in this case it does not work. I already pulled everything out of the repo.

Any clues? thanks! enter image description here

+6
source share
5 answers

You will be able to complete the transaction as soon as you make changes to / add the file. Adding a directory to git cannot be done on its own; you need to add / edit the file inside the directory.

Try adding something to css and then release it.

+10
source

Git only tracks files - when you run git add <directory> , what you are actually doing tells Git to add the contents of any files in this directory. Since the directory is currently empty, it does not add anything and therefore does not commit anything.

For example, the following will work:

 $ touch css/main.css $ git add css $ git commit -m "Add empty main CSS file" 
+4
source

As everyone says, git only tracks files, not directories. Thus, you cannot add an empty directory to it. You can do the trick by adding an empty .gitignore to the css directory and commit it.

+2
source

I think there are only two possibilities.

  • You are in the wrong directory.
  • You have a gitignore with blocks for adding folders / files.

You can check it out when you modify the file in the css directory and see

#git status

If the file is modified.

If there is no change, check the .gitignore files.

+1
source

For some strange reason, I had a databaseervices.demo / directory that would not be perfect. I changed the name to database services and did not become a problem. Maybe a problem with (.), Or maybe with the way I added files? I'm not sure, but changing (mv) the name worked for me.

0
source

All Articles