Git - Won't add files?

后端 未结 29 1990
小蘑菇
小蘑菇 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:33

    I am still a beginner at git, and it was just a stupid mistake I made, long story in one sentence. I was not in a subfolder as @gaoagong reported, but the other way round, in a parent folder. Strange enough, I did not get the idea from that answer, instead, the idea came up when I tested git add --all, see the long story below.

    Example in details. Actual repo:

    The Parent folder that I had opened mistakenly on parent level (vscode_git in my case):

    I had cloned a repo, but I had a parent folder above this repo which I had opened instead, and then I tried adding a file of the subfolder's repo with git add 'd:\Stack Overflow\vscode_git\vscode-java\.github\ISSUE_TEMPLATE.md', which simply did nothing, no warning message, and the git status afterwards said:

    nothing added to commit but untracked files present (use "git add" to track)

    Running git add --all gave me the yellow notes:

    warning: adding embedded git repository: vscode-java the embedded repository and will not know how to obtain it.

    hint: If you meant to add a submodule, use: git submodule add vscode-java

    hint: If you added this path by mistake, you can remove it from the index with git rm --cached vscode-java

    See "git help submodule" for more information.git

    To fix this, I reverted the git add --all with git rm --cached -r -f -- "d:\Stack Overflow\vscode_git\vscode-java" rm 'vscode-java':

    Then, by simply opening the actual repo folder instead,

    the git worked as expected again. Of course the ".git" folder of the parent folder could be deleted then:

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

    In my case the issue was enabled SafeCrLf option. I am on windows with tortoise git. After disabling the option adding the files was not an issue anymore.

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

    You can remove recursively the git initialised repo $cd repo added $git rm -rf git

    You can create a separate branch and link the submodules to the master branch The documentation on submodules is really useful Documentation [https://git-scm.com/book/en/v2/Git-Tools-Submodules]

    Also see some solutions in [https://stackoverflow.com/questions/36236484/maintaining-a-git-repo-inside-another-git-repo]

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

    I was having this issue on Visual Studio, what worked for me was: 1- Right click on the added file that is not being recognized by git. 2- Select "Add excluded file to Source Control"

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

    If the file is excluded by .gitignore and you want to add it anyway, you can force it with:

    git add -f path/to/file.ext
    
    0 讨论(0)
  • 2020-12-13 12:39

    Had the same issue with a repo that I cloned from SiteGround Git to my mac. The freshly cloned repo had a list of changed files that git status said needed to be added to the commit, but trying to add or checkout any of them didn't do anything at all.

    For some reason there were case changes in the filenames (e.g. .jpg -> .JPG). The solution was to simply git mv the filename the OS was using to the name git was using, e.g.:

    git mv File_That_Wont_Add.txt File_THAT_WONT_Add.txt
    
    0 讨论(0)
提交回复
热议问题