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

后端 未结 9 1278
死守一世寂寞
死守一世寂寞 2020-12-12 13:00

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 solu

相关标签:
9条回答
  • 2020-12-12 13:16

    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
    
    0 讨论(0)
  • 2020-12-12 13:16

    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

    0 讨论(0)
  • 2020-12-12 13:20

    If you have committed the bin and obj folders previously, adding them to .gitignore will not automatically delete them. You need to commit deleting these folders with for example git rm -rf obj or git rm -rf yourProject/obj then commit the deletion

    0 讨论(0)
  • 2020-12-12 13:22
    • 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
    0 讨论(0)
  • 2020-12-12 13:30

    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.

    0 讨论(0)
  • 2020-12-12 13:31

    In my case, bin and obj folders were nested under Project folder from the root .gitignore file, so I had to add it like below:

    [PROJECT_FOLDER_NAME]/bin
    [PROJECT_FOLDER_NAME]/obj

    Replace PROJECT_FOLDER_NAME with your project folder name

    0 讨论(0)
提交回复
热议问题