Git - Won't add files?

后端 未结 29 1988
小蘑菇
小蘑菇 2020-12-13 12:01

I\'m having issues where I can\'t add files to my repository.

I\'m using GIT on windows, in Aptana Studio for some Ruby development.

I\'ve managed to push a

相关标签:
29条回答
  • 2020-12-13 12:24

    I know this is a really old question, but I know it can happen to someone as well, turns out I was working with a file named AUX.JS and thi is a reserved file name for windows, this produced the following error

    fatal: unable to stat 'src/hoc/Aux.js': No such file or directory

    so you can either remove the file or rename it, then it will work.

    Final conclusion, in addition to all other valid answers, if you are in a windows machine look out for the output of the 'git add' command, it can also provide additional information.

    0 讨论(0)
  • 2020-12-13 12:24

    I had a problem where files from one folder wont get added to the Github source control. To solve that I deleted the .git folder that was created under that folder.

    0 讨论(0)
  • 2020-12-13 12:25

    It's impossible (for me) to add the first file to an empty repository cloned from GitHub. You need to follow the link README, that GitHub suggests to create. After you create your first file online, you can work normally with git.

    This happened to me Nov 17, 2016.

    0 讨论(0)
  • 2020-12-13 12:27

    Issue git would not add a changed file. Using git bash, I had changed folder delimiting the folder name with the double quote. ls displayed the folder contents correctly but git would not add changed files.

    Solution I used the single quote to delimit the folder name.

    e.g. CD "Folder Name" git status nothing to commit, working tree clean CD .. ls 'Folder Name' CD 'Folder Name' git status modified: ModifiedFileName.bat

    0 讨论(0)
  • 2020-12-13 12:28

    I found myself in a similar situation as the poster:

    If I call "git add .", and then "git status" and it keeps saying "working directory clean" and has nothing to commit.

    But I had a different solution than what's here. Since I came to this first, I hope to save others some time.

    From the above answers and what I've seen elsewhere, the usual fixes to this problem are:

    • Ensure there are actually saved changes on the file in question
    • Ensure the file doesn't meet your exclude rules in .gitignore and .git/info/exclude
    • Ensure you're not trying to add an empty folder. Git won't track those. Standard solution is to place a blank file named .gitkeep as a placeholder so git will track the folder.

    In my case, I had originally tried to create a git repo around an existing repo (not knowing it was there). I had removed the .git folder from this sub repo a while ago, but I didn't realize that it was too late, and git was already tracking it as a submodule. You can read more about how these behave and how to remove them here, but

    • the solution for me was to simply run git rm --cached path_to_submodule.
    0 讨论(0)
  • 2020-12-13 12:29

    I had the same problem and it was because there was a program using some file and git throws an error in this case Visual Studio had locked that file.

    0 讨论(0)
提交回复
热议问题