0

I'm new to coding.

I learned about the .gitignore file today, and I succeeded in adding an unwanted file to the .gitignore file but could not add one file on the .gitignore file.


Untracked files:
  (use "git add <file>..." to include in what will be committed)
    ".zcompdump-Young\342\200\231s MacBook Pro (3)-5.8.1"
    git/

I don't want this file to be on my untracked file list.

How can I include this in the .gitignore file?

Why isn't this file included in .gitignorefile as other files?

I was able to add these files in the .gitignore file.

.zshrc
.python_history
.stCommitMsg
.subversion/
.viminfo
.vscode/
Applications/
Creative Cloud Files/
Desktop/
Documents/

and when I enter git status commend these files weren't not appeared in the untracked list.

What am I doing wrong? How can I add it to the .gitignore file?

CryptoFool
  • 21,719
  • 5
  • 26
  • 44
calipalm
  • 3
  • 4
  • if you have already initiated a git repository before setting up the `.gitignore`, then the file will always be tracked, even if you include it in the ignore file later. Your only choice is to remove the `.git` directory and create the `.gitignore` then initiate the repo again – Ahmad Oct 18 '22 at 04:04
  • Why can't you add that file to the `.gitignore` file? You could add it as a prefix, like `.zcompdump*`. – CryptoFool Oct 18 '22 at 04:11

2 Answers2

1

If you're having to ignore Applications, Desktop and Documents, it looks like you're on a Mac and that you've initialized a Git repository in your home directory.

Don't do that.

Create a subdirectory (call it Development for all I care) and put your projects in subdirectories of that one. Then you initialize a Git repository per project directory.

Then delete the .git directory from your home dir.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
  • can you tell me the reason why I should create a subdirectory? or recommend articles to read to understand this concept? before I do, I know why... Thank you so much! – calipalm Oct 18 '22 at 17:18
  • Because where else are you storing your project? You're bound to create another one in the future. So just give each their own directory. – CodeCaster Oct 18 '22 at 19:47
0

Add the .zcompdump-Young/ to your .gitingore and make after modifying .gitignore you add it with git add .gitignore then check git status

Your .gitignore file should look like this:

.zshrc
.python_history
.stCommitMsg
.subversion/
.viminfo
.vscode/
Applications/
Creative Cloud Files/
Desktop/
Documents/
.zcompdump-Young/
rafathasan
  • 524
  • 3
  • 15