I've researched this and I can't seem to bump on a working solution. I have a repo locally and want to ignore everything in it except two files, since those are the only ones necessary to build the program.
What I've tried is this:
Contents of .gitignore:
# Ignore everything
*
# not these files...
!.gitignore
!ApiTest/KLM_Service.cs
!ApiTest/Program.cs
The structure of my repo is this:
.git
ApiTest
bin
obj
Properties
App.config
KLM_Service.cs
Program.cs
.gitignore
I'm on Windows using GIT Bash.
Any ideas on how to solve this?
Based on your repo layout, I would strongly recommend against ignoring everything. While there are a lot of autogenerated files that you don't care about, the autogenerated filenames will never change. Your source code filenames will definitely change, though, which would force you to keep your .gitignore
constantly up-to-date.
Since this is C# code, why don't you use a C#-specific .gitignore to start off, like this one ?
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.