How could I ignore bin and obj folders from git repository?

余生长醉 提交于 2019-12-17 23:02:01

问题


I want to ignore bin and obj folders from my git repository. As I've found out, there is no easy way to do this in .gitignore. So, are there any other way? Using clean solution in Visual Studio?


回答1:


I'm not sure why this doesn't work for you. In case it helps, here's a typical .gitignore file from one of my Visual Studio/git projects:

*.suo
*.user
_ReSharper.*
bin
obj
packages



回答2:


simply making an entry in gitignore may not ignore files, you may need to commit it. I used the following method and worked for me

git rm -r --cached .

git add .

then

git commit -am "Remove ignored files"

However, this ignores my scripts folder which I included later into the repository.




回答3:


If you want to ignore bin and obj in ALL your projects then you can use (from gitignore man page)

Patterns read from the file specified by the configuration variable core.excludesfile.

core.excludesfile can be set in a config file which is ~/.gitconfig in Unix - I don't know where it is under Windows




回答4:


  • Locate the bin and obj folders in Windows Explorer
  • Right click TortoiseGit > Delete and add to ignore list > bin
  • Right click TortoiseGit > Delete and add to ignore list > obj



回答5:


If you try through source tree and still the ignore files are not coming in , go to tools-->option->Git and then select location of the .gitignore




回答6:


If you are using Visual Studio then there is a simple way to do this.

  1. Open Team Explorer
  2. Click on settings
  3. Repository Settings
  4. Under Ignore & Attribute file section Click on Add beside Ignore file.

It will create a default .gitignore file, which will ignore most of common folders & files that will used by framework/language.



来源:https://stackoverflow.com/questions/2347335/how-could-i-ignore-bin-and-obj-folders-from-git-repository

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!