Why doesn't git recognize that my file has been changed, therefore git add not working

前端 未结 24 2246
野趣味
野趣味 2020-12-04 08:07

I am trying to push my files to github using bash. They are already on there, and I am uploading a newer version with new lines and code, etc. But when I try git add<

相关标签:
24条回答
  • 2020-12-04 08:28

    My Git client (Gitg) caused this issue for me. Normal commands that I would usually run weren't working. Even touching every file in the project didn't work.

    I found a way to fix it and I'm still not sure what caused it. Copy your project directory. The missing files will show up in the copied directory's git status. Renaming might do the same thing.

    0 讨论(0)
  • 2020-12-04 08:30

    Sometimes depend and by git version and if you forget to do git add ..

    To check about your change on repository use always git status that show all untracked and changed files. Because git diff show only added files.

    0 讨论(0)
  • 2020-12-04 08:31

    I had a similar issue while using Sublime Text-3. After making new changes in the code and saving it, when I tried the git add ./status commands the response was "branch already-up to date". I figured out, regardless saving the updates in the text editor, the file was actually unchanged. Opening file in other editor and saving the changes worked for me.

    0 讨论(0)
  • 2020-12-04 08:32

    Check your .gitignore file. You may find that the file, or extension of the file, or path to the file you are trying to work with matches an entry in .gitignore, which would explain why that file is being ignored (and not recognized as a changed file).

    This turned out to be the case for me when I had a similar problem.

    0 讨论(0)
  • 2020-12-04 08:32

    TL;DR; Are you even on the correct repository?

    My story is bit funny but I thought it can happen with someone who might be having a similar scenario so sharing it here.

    Actually on my machine, I had two separate git repositories repo1 and repo2 configured in the same root directory named source. These two repositories are essentially the repositories of two products I work off and on in my company. Now the thing is that as a standard guideline, the directory structure of source code of all the products is exactly the same in my company.

    So without realizing I modified an exactly same named file in repo2 which I was supposed to change in repo1. So, I just kept running command git status on repo1 and it kept giving the same message

    On branch master

    nothing to commit, working directory clean

    for half an hour. Then colleague of mine observed it as independent pair of eyes and brought this thing to my notice that I was in wrong but very similar looking repository. The moment I switched to repo1 Git started noticing the changed files.

    Not so common case. But you never know!

    0 讨论(0)
  • 2020-12-04 08:35

    Did you move the directory out from under your shell? This can happen if you restored your project from a backup. To fix this, just cd out and back in:

    cd ../
    cd -
    
    0 讨论(0)
提交回复
热议问题