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

前端 未结 24 2353
野趣味
野趣味 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: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!

提交回复
热议问题