简体   繁体   English

除了几个文件,我如何忽略我回购中的所有内容?

[英]How do I ignore everything in my repo except a few files?

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: .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. 我在Windows上使用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. 但是,您的源代码文件名肯定会更改,这将迫使您不断更新.gitignore

Since this is C# code, why don't you use a C#-specific .gitignore to start off, like this one ? 由于这是C#代码,因此为什么不使用C#专有的.gitignore像这样开始?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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