How to ignore files while committing code on GitHub using Visual Studio?


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.


Asked by:- bhanu
0
: 7929 At:- 8/12/2020 10:23:47 AM
Visual Studio add gitignore files







2 Answers
profileImage Answered by:- vikas_jk

Here are the steps to do it using Visual Studio:

  1. Click on Team explorer in Visual Studio ( You can also open it from "View"-> "Team Explorer")
  2. Click on "Home" icon on top of it
  3. Click the settings option.
  4. Then click Repository Settings.
    /Visual-Studio-Team-Explorer-Repository-Settings.png
  5. Now click the add link next to the Ignore File description. This will add the .gitignore file will all the defaults set for things that should be ignored.
  6. your file should look like this
    ## 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.

1
At:- 8/18/2020 8:17:47 AM
Thanks, it works as needed. 0
By : bhanu - at :- 8/20/2020 2:17:25 PM


profileImage Answered by:- pika

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.

0
At:- 6/3/2022 7:55:22 AM






Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use