Hello, I am using Visual Studio and I was constantly adding "/bin/projectname.dll" files on GitHub until now, but now I want to ignore these .dll files. So How can I ignore these build files and push only files like .cs, .html,.js ,.css etc to GitHub Repository.
Here are the steps to do it using Visual Studio:
## 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
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/?
Save and commit it, this should work.
In Visual Studio, you can directly Click on "Git" -> "Settings" -> Then select "Git Repository settings" -> then in section "Git Files", click the Add button for Ignore file.
If file is already you will see "Edit" button instead of "Add"
Here is how my GitIgnore file looks like
ProjectName/obj/
###################
# compiled source #
###################
*.com
*.class
*.dll
*.exe
*.pdb
*.dll.config
*.cache
*.suo
.vs
# Include dlls if they’re in the NuGet packages directory
!/packages/*/lib/*.dll
!/packages/*/lib/*/*.dll
# Include dlls if they're in the CommonReferences directory
!*CommonReferences/*.dll
####################
# VS Upgrade stuff #
####################
UpgradeLog.XML
_UpgradeReport_Files/
###############
# Directories #
###############
bin/
obj/
TestResults/
###################
# Web publish log #
###################
*.Publish.xml
#############
# Resharper #
#############
/_ReSharper.*
*.ReSharper.*
############
# Packages #
############
# it’s better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
######################
# Logs and databases #
######################
*.log
*.sqlite
# OS generated files #
######################
.DS_Store?
ehthumbs.db
Icon?
Thumbs.db
[Bb]in
[Oo]bj
[Tt]est[Rr]esults
*.suo
*.user
*.[Cc]ache
*[Rr]esharper*
packages
NuGet.exe
_[Ss]cripts
*.exe
*.dll
*.nupkg
*.ncrunchsolution
*.dot[Cc]over
In Visual Studio 2017, you can just right click on the solution file and select Add solution to source control, this will add .gitignore file and .gitattributes
In Visual Studio 2015 Team Explorer -> Local Git Repositories -> Project -> Settings -> Git -> Repository Settings -> Ignore & Attribute Files.
You can add .gitignore file with items should be ignored in visual studio solutions by default.
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly