0

I have created a new repository on github for a project, cloned it and pushed 2 files: README.md and main.c.

But for some reason every time I try to use

 git status

or

git add .

to commit changes, I get the following message

# On branch master
nothing to commit (working directory clean)

So I can't push anything and the only workaround solution that works is

rm -rf .git
git init
git remote add origin <repo>

and force pushing the files. After I push the changes it goes back to the 'nothing to commit' message,so I have to reinitialise every time I want to commit.

This problem occurs even when I try to reclone the repository.

I've looked around for solutions, it seems that .gitignore can sometimes cause similar issues but I don't have a .gitignore file in the repo.

kawaiinekochan
  • 212
  • 3
  • 12
  • You said that you cloned **and committed** 2 files. Therefore, it is expected that after running "git add ." you'll get "nothing to commit". – Maria Ines Parnisari Mar 20 '15 at 17:48
  • 1
    Maybe a global ignore file? See http://stackoverflow.com/q/7335420/2404501 - or more likely @l19 is right and you're not doing the whole "modify, `git add`, `git status`, `git commit`" sequence in the right order. –  Mar 20 '15 at 17:48
  • @WumpusQ.Wumbley I don't have a global ignore file on my machine either.. I've been using git for a year now and I am quite familiar with how to commit and push files, so I really don't think that's the problem – kawaiinekochan Mar 20 '15 at 18:05

1 Answers1

4

What is the output of git status -s --ignored? If you see anything with a !! at the front, then that means it's being ignored somehow. You have to explicitly add anything that is being ignored. Moreover, you have to use git add -f to force it, otherwise git will yell at you saying the file is being ignored. For example: git add -f path/to/ignored_file.txt

John Szakmeister
  • 44,691
  • 9
  • 89
  • 79