Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gitignore - fatal: no files added

Tags:

git

I have an issue with git, more precisely with gitignore.

I have created an empty folder Initialized git

mkdir fold cd fold git init 

Updated gitignore (as below)

 *.prjx 

Committed gitignore

git add .gitignore git commit -m "update gitignore" 

Now I have several files (among them a .prjx) and folders in my root (fold) and I'd like to add all of them, but when I run

git add * 

I get the message below

The following paths are ignored by one of your .gitignore files: ftc.prjx Use -f if you really want to add them. fatal: no files added 

I don't want to add it, I simply want add all the other files and folders. From my understanding .gitignore should handle exactly that so why I get the message above? Am I missing something?

like image 697
Sig Avatar asked Aug 23 '12 03:08

Sig


People also ask

Why is .gitignore not ignoring my files?

gitignore ignores only untracked files. Your files are marked as modified - meaning they were committed in the past, and git now tracks them. To ignore them, you first need to delete them, git rm them, commit and then ignore them. Igal S.

How do I add files to Gitignore?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.

Why isn't my Gitignore working?

The Solution To resolve the problem remove from the repository the tracked files contained in the . gitignore file. To achieve this use “git rm” to remove and untrack all the files in the repository, then use “git add” to re-add all the files (the files contained in the .

How do I ignore an already tracked file in Git?

Simply move the files to a folder outside of git, then do "git add .", "git commit". (This removed the files) then add the gitignore, referencing the files/folders, commit again to add the gitignore file to git, then copy/move back in the folders, and they should be ignored.

What is a Git ignore file?

A .gitignore file is a plain text file that contains a list of all the specified files and folders from the project that Git should ignore and not track. Inside .gitignore, you can tell Git to ignore only a single file or a single folder by mentioning the name or pattern of that specific file or folder.

How do I force a file to be added to gitignore?

It is possible to force an ignored file to be committed to the repository using the -f (or --force) option with git add: $ cat.gitignore *.log $ git add -f debug.log $ git commit -m "Force adding debug.log" You might consider doing this if you have a general pattern (like *.log) defined, but you want to commit a specific file.

What is the use of gitignore?

This method can be used for locally-generated files that you don’t expect other users to generate, like files created by your editor. There are no other .gitignore files in the repository, nor is there anything in the .git/config file that ignores anything. How is .git/info/exclude configured? It's not clear why this answer is marked as answered.

How do I test gitignore?

Each pattern in a particular.gitignore file is tested relative to the directory containing that file. However the convention, and simplest approach, is to define a single.gitignore file in the root. As your.gitignore file is checked in, it is versioned like any other file in your repository and shared with your teammates when you push.


1 Answers

you should run git add . rather than git add *

the * is interpreted by the shell and substituted with all file and folder in the current location. obviously ftc.prjx is one of them and git is just warning that the file is in the ignorelist.

like image 135
Olivier Refalo Avatar answered Oct 05 '22 21:10

Olivier Refalo