Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between git ignore and untrack

Tags:

git

gitignore

What's the difference between ignore a folder and untrack in git? I need to remove some folders from my git repository and I am working in Netbeans with the git plugins and put by mistake the build, dist, and nbproject folders in my repository and now I need to remove those folders.

like image 404
Premier Avatar asked Feb 24 '14 14:02

Premier


People also ask

What is the difference between Gitignore and exclude?

git/info/exclude is the same as . gitignore, just a lower precedence and not in the repository (so, not committed and shared). Neither affects already tracked files. Both affect files that are not currently tracked.

What is git Untrack file?

Untracked files are files that have been created within your repo's working directory but have not yet been added to the repository's tracking index using the git add command.

What is the purpose of git ignore?

When Do You Use Git Ignore File? The git ignore file rule allows you to ignore a file you've committed in the past. You use it when you do not want to recommit a file, for example a build artifact.

How do I ignore Untrack files?

You can use the git clean command to remove untracked files. The -fd command removes untracked directories and the git clean -fx command removes ignored and non-ignored files. You can remove untracked files using a . gitignore file.


1 Answers

If you create a file in your repository named .gitignore, git will use its rules when looking at files to commit. git will not ignore a file that was already tracked (i.e. was in the repo) before a rule was added to this file to ignore it. File must be un-tracked (removed from the repo) using

git rm --cached filename 

The command will stop tracking but keep the file there intact.

like image 148
Niya Avatar answered Oct 25 '22 12:10

Niya