简体   繁体   中英

How to remove (not ignore) specific files using .gitignore?

Below is the image of my project structure:

在此处输入图片说明

I would like to delete .vs folder, packages folder, .hgignore file and bin and obj directories under Leapfrog.Datafetcher, Leapfrog.Test, and src/LeapfrogDataService.

As of now, my .gitignore file looks like

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
packages
.hgignore

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/

# Visual Studio 2015 cache/options directory
.vs/

Can anyone let me know what is missing in a .gitignore file or is there anything wrong with my path?

.gitignore will not delete anything. All it does is ignore certain paths when you are trying to git add or git commit . If the files are already being tracked by git, adding them to .gitignore will prevent you from making further changes (in git) to those files, but it won't delete existing history.

If you want to remove these files from your repository, you need to use git rm (or git rm -r to recursively remove a directory and its contents).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM