Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.gitignore and web.release.config

I'm trying to remove my web.release.config from my GIT repository, so I removed it from git with git rm and then added it to my .gitignore file.

But as soon as I copy again the file into the project, it gets added by Visual Studio to the pending changes.

This is the line in the gitignore file:

Web.Release.config

But it gets added:

enter image description here

enter image description here

How can I successfully remove web.release.config from git?

like image 987
Escobar5 Avatar asked Oct 01 '14 13:10

Escobar5


People also ask

Where should .gitignore be placed?

gitignore file tells Git which files to ignore when committing your project to the GitHub repository. gitignore is located in the root directory of your repo. / will ignore directories with the name.

Should .gitignore be added to repository?

Normally yes, . gitignore is useful for everyone who wants to work with the repository. On occasion you'll want to ignore more private things (maybe you often create LOG or something. In those cases you probably don't want to force that on anyone else.

What is the purpose of the .gitignore file?

The purpose of gitignore files is to ensure that certain files not tracked by Git remain untracked. To stop tracking a file that is currently tracked, use git rm --cached.

How do I ignore a .cache file in Git?

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.


2 Answers

  • After adding files to the .gitignore file, to ignore those files we have to execute some commands.
  • To ignore the files which we mentioned in the .gitignore file, we have to execute the following commands.

    git rm -r --cached . git add . git commit -m ".gitignore is now working"

  • Please refer this question once.

like image 96
Anjaneyulu Battula Avatar answered Oct 16 '22 23:10

Anjaneyulu Battula


This might not be a "proper" answer, but I think it's Visual Studio messing around. I've been experiencing the same problem with Visual Studio 2013 when I tried to exclude NuGet packages from the repository. git status shows nothing, while VS still shouting that there're hundreds of files pending to be added. I ended up just use a Git Client (Git Extension, which is bundled with the git installation package) and ignore that Team Explorer tab in VS completely.

like image 26
Ngoc Pham Avatar answered Oct 16 '22 23:10

Ngoc Pham