I'm trying to add two directories to a git repo. I can add them OK, but when trying to "commit", I get "nothing to commit". I'm following the add->commit->push sequence, but in this case it doesn't seem to be working. I have already pulled everything from the repo.
Any hints?
thanks!
The Git “nothing to commit, working directory clean” message tells us that we have not made any changes to our repository since the last commit. If this message appears and the contents of your remote repository are different to your local repository, check to make sure you have correctly set up an upstream branch.
Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed. Enter git commit -m '<commit_message>' at the command line to commit new files/changes to the local repository.
When do you use git add ? As you're working, you change and save a file, or multiple files. Then, before you commit, you must git add . This step allows you to choose what you are going to commit.
Git doesn't like empty folders. It doesn't include them in commits and it certainly doesn't include an empty directory when you push to GitHub or GitLab.
You will be able to commit as soon as you make a change to/add a file. Adding a directory to git can't be commited itself; you need to add/edit a file inside the directory.
Try adding something in css and comitting afterwards.
Git only tracks files - when you run git add <directory>
, what you're actually doing is telling Git to add the contents of any files in that directory. Since the directory is currently empty, it doesn't add anything, and thus there's nothing to commit.
For instance, the following would work:
$ touch css/main.css
$ git add css
$ git commit -m "Add empty main CSS file"
As everybody says, git track only files, not directories. So you can't add empty directory into it. You can make a trick by adding empty .gitignore
in directory css
and commit it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With