1

Having a strange problem in my gits. There is nothing to add, yet it won't let me switch or add the files suggested to add.

git status
# On branch oop
nothing to commit (working directory clean)

git checkout LIVE
error: The following untracked working tree files would be overwritten by checkout:
    folder/file.js
    folder/file2.js
Please move or remove them before you can switch branches.
Aborting

Even after doing git add folder/file.js;git add folder/file2.js, the same results occur.

Anyone have any idea what's going on? There is no .gitignore file...

Strangely, before, I could not add these files in, so I had to rename, add, rename them to get them in the repo (as suggested by this answer.

Could it be related to the fact that this folder used to be its own repo within this repo? I deleted all hidden folders (like .git) within this folder.

Community
  • 1
  • 1
d-_-b
  • 21,536
  • 40
  • 150
  • 256
  • They are most probably part of your current branch's `.gitignore`, but not ignored on the LIVE branch. – Nevik Rehnel Feb 10 '13 at 22:18
  • i've checked the .gitignore file in the repo's folder, as well as my home folder, they are both empty. – d-_-b Feb 10 '13 at 22:19
  • You can use `git status --ignored` to include ignored files. If they show up there, they're getting ignored from *somewhere*. – Nevik Rehnel Feb 10 '13 at 22:22
  • good idea, but nothing shows up using `--ignored` either :/ – d-_-b Feb 10 '13 at 22:23
  • possible duplicate of [GIT: The following untracked working tree files would be overwritten by checkout](http://stackoverflow.com/questions/12323128/git-the-following-untracked-working-tree-files-would-be-overwritten-by-checkout) – CharlesB Feb 10 '13 at 22:37
  • @CharlesB, not really the same. I can't add the files as they already were added (i.e. `git status` shows nothing. and `git status --ignored` shows nothing.) – d-_-b Feb 10 '13 at 22:42

3 Answers3

1

Not sure what the problem was, but I did the following to fix it:

  • deleted the folder (and saved a backup)
  • git add -u; // stage deleted files
  • git commit -m '...'
  • copied backup files into repo's folder
  • git add . // stage new files
  • git commit -m '...'

did this in both branches and it seemed to fix it so far..

d-_-b
  • 21,536
  • 40
  • 150
  • 256
0

there could also be submodules and other .gitignore files. Double check your exclude file if you use one as well.

Clone this repo locally. See if the checkout works on the clone.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
  • hey, this was all done on a clone. once i noticed the problem i deleted everything and cloned it to try again. `git status --ignored` didn't return anything. very strange problem – d-_-b Feb 10 '13 at 22:37
0

Remember that adding a file only stages the files. It does not commit them to the repo. After using git add, you also need to do a git commit to commit the changes.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268