Why does “git status” show way too much untracked files?

后端 未结 3 2095
轻奢々
轻奢々 2021-02-14 00:48

Answer in the bottom.

I am trying to see the status of my files in the git_test2 directory which contains 3 files named

相关标签:
3条回答
  • 2021-02-14 01:10

    As you see, file paths starts with ../... Git status always shows all changes in current repositroty, not only in current directory. As you see, it actually shows changes in repository, in which you are at least 2 folders deep. But there are no files test1.txt.

    So, check with pwd that you're in right directory (maybe you're in another repo currently).

    0 讨论(0)
  • 2021-02-14 01:17

    Hmm i looks a bit that you have your .git folder not in your product but i few folder above. Then when you are in your project and you make a git status and you see ../../ that means that you are on the second level in your Git repository.

    Perhaps you should clone that repository again and check you git structure.

    0 讨论(0)
  • 2021-02-14 01:30

    Why are there so many files?

    A git repository is just a .git/ directory (folder) located in your project's directory. Like this: myproject/.git/.

    If there's no git repository in your current directory, git searches in the parent directory, then in parent's parent and up to top.

    As your path was /Users/ishayfrenkel1/Desktop/git_test2, there should be a git repo somewhere in this path.

    new file:   ../../Library/Preferences/AndroidStudio1.2/options/git.xml
    

    New files have path at least two levels up from /Library (which is either /Library or /Users/ishayfrenkel1/Library). It means that you have a git repository initiated:

    • either in your home directory: ~/, /Users/<username>/ on OSX or /home/<username> on Linux.
    • or in the root directory, /, the parent of all directories.

    How it happened.

    Most probably you opened the Terminal and typed git init. Terminal opens in your home directory by default and that's where the new repository was created.

    What to do now.

    Search for it and delete it. One of the following commands should run without an error. And there it is!

    ls /.git
    ls ~/.git
    

    Now remove the repository with

    rm -rf ~/.git
    
    0 讨论(0)
提交回复
热议问题