简体   繁体   中英

How do I solve a history list of untracked files before making git commits for a current project?

I want to add 2 text files to a {master} project but I keep getting a list of untracked files that have nothing to do with my current project. Why is this happening and how can I solve it? MacOS v10.15.7 Catalina Terminal

Added 1st text file:

git add file1.txt

Added 2nd text file:

git add file2.txt

Viewing working directory and staged files:

git status

Changes to be committed:

new file: file1.txt

new file: file2.txt

PLUS Keep getting a list of Untracked Files:

    .Trash/
    .anaconda/
    .config/
    .idlerc/
    .ipython/
    .local/
    .matplotlib/
    .npm/
    .spyder-py3/
    .vscode/
    Applications/
    Creative Cloud Files/
    Desktop/
    Documents/
    Downloads/
    Library/
    Moon/
    Movies/
    Music/
    Pictures/
    Public/
    helloworld/
    opt/

I deleted pronto!

rm -rf ~/.git

Checked

git status

Output

fatal: not a git repository (or any of the parent directories): .git

I'll start my project all over again, more aware!

It looks like you initialized git in your home directory. You probably want to initialize it in the project directory of the software you are creating. Each project should have its own git repo. You can remove the git repo from your home folder by moving it to another directory or deleting it entirely using rm -Rf ~/.git (note: this is not undoable!) Once you have done that, cd into the folder/project you want to track and do another git init :

cd <some project folder>
git init
git add file1.txt

If you meant to put your entire home directory into git (which I don't recommend), you'll have to either put all the directories and files you don't want to track into the .gitignore file or just manually add the two files using git add file1.txt . Git tracks any files in its directory unless they are explicitly put into gitignore.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM