Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - Freshly pulled branch shows untracked files

Tags:

git

Just pulled a branch which another developer was working on it. I haven't changed anything at all. Just pulled and run git status and git shows that ../.eslintcache is untracked and is suggesting to include it in what will be committed.

What should I do? I don't think that I should add and commit it.

like image 662
user1941537 Avatar asked Sep 12 '19 15:09

user1941537


People also ask

What happens to untracked files when git pull?

git pull doesn't delete uncommitted changes, it doesn't deal with your working directory, any changes or new files will not be touched unless it committed.

Will reset hard remove untracked files?

git reset --hard resets your index and reverts the tracked files back to state as they are in HEAD. It leaves untracked files alone.


2 Answers

Add folders and files you don't want to have in your repo to .gitignore

Here is more info about that file: https://git-scm.com/docs/gitignore

For instance files generated by IDEs and tools used while development are usually added there. Like .eslintcache folder added by eslint. This might happen because you added this folder to your IDE, which probably runs linting and other check ups running in the background.

In your case .gitignore might look like:

.eslintcache

#JetBrains IDE
.idea/
like image 94
R A Avatar answered Oct 09 '22 03:10

R A


It's a leftover of you previous work.

  • How it appeared?

Either you made linting, ot is is a part of some other job/script. In .eslintcache some linters caching occurs, and during this process it was created.

  • Why it didn't disappear when you checkouted other branch?

When you checking out new branch all untracked files will be still reside in you directory, unless there will be some conflicts.

  • How to avoid this?

You should add generated files (like .eslintcache) which you don't want to appear in git status, to be omited by git to .gitignore.

like image 34
Rumid Avatar answered Oct 09 '22 03:10

Rumid