Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git:nothing added to commit but untracked files present

Tags:

git

I'm new to Git and is using for the very first time. I would appreciate if someone could help me out. I tried finding the answer at forums,but there are tons of commands that are coming out and not sure which one to use.

On the prod server, if I do the git pull, it is giving me the following error:

Untracked files: (use "git add ..." to include in what will be committed)

Optimization/language/languageUpdate.php email_test.php nothing added to commit but untracked files present (use "git add" to track) Please move or remove them before you can merge. 

I'm not too sure how to make it work. If I remove them, from where would it be removed. Appreciate your reply.

like image 644
user4943236 Avatar asked Nov 04 '15 03:11

user4943236


People also ask

Does git commit add untracked files?

Untracked basically means that Git sees a file you didn't have in the previous snapshot (commit), and which hasn't yet been staged; Git won't start including it in your commit snapshots until you explicitly tell it to do so.

Why do I have untracked files in git?

Untracked files are those that are in the repo's directory but have not yet been added to the repo's index with git add .

Does git add all add untracked files?

The easiest way to add all files to your Git repository is to use the “git add” command followed by the “-A” option for “all”. In this case, the new (or untracked), deleted and modified files will be added to your Git staging area.


2 Answers

Also instead of adding each file manually, we could do something like:

git add --all 

OR

git add -A 

This will also remove any files not present or deleted (Tracked files in the current working directory which are now absent).

If you only want to add files which are tracked and have changed, you would want to do

git add -u 

What is the difference between git add . & git add --all?

like image 40
Viv Avatar answered Oct 31 '22 04:10

Viv


You have two options here. You can either add the untracked files to your Git repository (as the warning message suggested), or you can add the files to your .gitignore file, if you want Git to ignore them.

To add the files use git add:

git add Optimization/language/languageUpdate.php git add email_test.php 

To ignore the files, add the following lines to your .gitignore:

/Optimization/language/languageUpdate.php /email_test.php 

Either option should allow the git pull to succeed afterwards.

like image 121
Tim Biegeleisen Avatar answered Oct 31 '22 04:10

Tim Biegeleisen