Rubymine: How to make Git ignore .idea files created by Rubymine

前端 未结 18 2062
隐瞒了意图╮
隐瞒了意图╮ 2020-12-07 08:35

I use Rubymine for Rails projects. Very often, Rubymine makes changes in .idea/* files that I don\'t care about. But it keeps preventing me from checking out ne

18条回答
  •  青春惊慌失措
    2020-12-07 09:12

    While it's not been too long that I made the switch to Rubymine, I found it challenging ignoring .idea files of Rubymine from been committed to git.

    Here's how I fixed it

    If you've not done any staging/commit at all, or you just spinned up a new project in Ruby mine, then simply do this

    Option 1

    Add the line below to the .gitignore file which is usually placed at the root of your repository.

    # Ignore .idea files
    .idea/
    

    This will ensure that all .idea files are ignored from been tracked by git, although they will still remain in your project folder locally.

    Option 2

    If you've however done some staging/commit, or you just opened up an existing project in Ruby mine, then simply do this

    Run the code in your terminal/command line

    git rm -r --cached .idea
    

    This deletes already tracked .idea files in git

    Next, include .idea/ to the .gitignore file which is usually placed at the root of your repository.

    # Ignore .idea files
    .idea/
    

    This will ensure that all .idea files are ignored from been tracked by git, although they will still remain in your project folder locally.

    Option 3

    If you've however done some staging/commit, or you just opened up an existing project in Ruby mine, and want to totally delete .idea files locally and in git, then simply do this

    Run the code in your terminal/command line

    git rm -r --cached .idea
    

    This deletes already tracked .idea files in git

    Run the code in your terminal/command line

    rm -r .idea
    

    This deletes all .idea files including the folder locally

    Next, include .idea/ to the .gitignore file which is usually placed at the root of your repository.

    # Ignore .idea files
    .idea/
    

    This will ensure that all .idea files are ignored from been tracked by git, and also deleted from your project folder locally.

    That's all

    I hope this helps

提交回复
热议问题