본문 바로가기

wrkbrs

IntelliJ .ide 제외시키기 본문

Git

IntelliJ .ide 제외시키기

zcarc 2019. 2. 2. 12:11


https://stackoverflow.com/questions/36839838/gitignore-does-not-ignore-idea-directory/36839990

https://stackoverflow.com/questions/22585818/how-to-add-files-folders-to-gitignore-in-intellij-idea



원격 저장소에서 삭제시키고 add, commit

플러그인으로 .gitignore 를 생성해고 add, commit

그다음 push




참고 1.

9

Working on a Symfony2 project using phpStorm IDE, I have added couple of files to git ignore but one file despite being added to git ignore is always appearing....I have tried multiple times but its always there

.gitignore file:

/app/config/parameters.yml
/bin/
/build/
/composer.phar
/vendor/
/web/bundles/
/app/bootstrap.php.cache
/app/cache/*
!app/cache/.gitkeep
/app/config/parameters.yml
/app/logs/*
!app/logs/.gitkeep
/app/phpunit.xml

#IDE metadata
**.idea/**

#Bash files
run.sh

And it is the .idea folder/files that git just will not ignore:

On branch develop
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   .idea/workspace.xml

no changes added to commit (use "git add" and/or "git commit -a")

Any idea why git will just not ignore the whole directory like i have specyfied in gitignore...?

22

Git never ignores changes to tracked files. As it appears as modified, the file is under version control (the idea/workspace.xml file usually should not be) and thus changes to it are tracked. Delete it from the index, leaving your local copy intact with git rm --cached .idea/workspace.xml and commit this change. From then on it will be ignored unless you force-add it back to the repository or change your gitignore settings.

  • Ok let me see if I understand this, So once you commit a file and then decide to add this file to gitignore, git will track changes to this file anyway as it exists in git cache crated during the first commit including that file...? If I understand this right is there a way to view git cache content...? – John Apr 25 '16 at 14:07
  • You don't even have to commit. As soon as you add a file to the index it is tracked, no matter what is written in any gitignore file. About your other question. "Git Cache" is not an official term, so I'm not sure what you are referring to exactly. What do you want to know? – Vampire Apr 25 '16 at 14:12
  • Ok i c thx, I would like to see a list of all the files that are being tracked by git – John Apr 25 '16 at 14:15
  • is it this command: git ls-files ? – John Apr 25 '16 at 14:16
  • git ls-tree -r --full-tree --name-only <tree-ish> – Vampire Apr 25 '16 at 14:21
13

Once you commit the file it will begin to be tracked.
In order to remove the file from this point you have to remove them from the repository.

What you need to do now is to delete the entire .idea folder, commit the deletion, add the ideaextension to your .gitignore file.

Note

You can still ignore added files with the assume-unchanged flag

--[no-]assume-unchanged

When this flag is specified, the object names recorded for the paths are not updated.
Instead, this option sets/unsets the "assume unchanged" bit for the paths.

When the assume unchanged bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index.

If you want to change the working tree file, you need to unset the bit to tell Git.

Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.


Explaining how to do from command line, can be done via IDEA as well.

# Remove the file from the repository
git rm --cached .idea/

# now update your gitignore file to ignore this folder
echo '.idea' >> .gitignore

# add the .gitignore file
git add .gitignore

git commit -m "Removed .idea files"
git push origin <branch>
  • Never ever use the --assume-unchanged flag, except you are a real Git crack and know exactly what you do. Otherwise you just risk your files. Its usage is constantly discouraged in #git in IRC and not without reason – Vampire Apr 25 '16 at 12:19
  • The main problem is that you can forget to turn it "off" and lose changes. – CodeWizard Apr 25 '16 at 12:20
  • 1
    Well, the average user will forget that this switch exists 5 minutes after he had used it. ;-) – Vampire Apr 25 '16 at 12:57
  • git rm --cached -r .idea/ now – Wajdy Essam Feb 24 '18 at 19:11

Your Answer






참고 2.












49

I try to switch from Eclipse to IntelliJ IDEA. I have a project that uses Git and I want to quickly add files to .gitignore file. In Eclipse I can right click on a file/directory and choose 'Add to .gitignore'.

Is there anything like this in IntelliJ IDEA or I have to edit the file manually?

58

EDIT: Intellij has a plugin as of now (2016): https://plugins.jetbrains.com/plugin/7495?pr=idea. Look at the answer below by biniam_Ethiopia

ORIGINAL ANSWER
As far as I can see IntelliJ has no option to click on a file and choose "Add to gitignore" like Eclipse has.

The quickest way to add a file or folder to gitignore without typos is:

  1. Right-click on the file in the project browser and choose "Copy Path" (or use the keyboard shortcut that is displayed there)
  2. Open the .gitignore file in your project, and paste.
  3. Adjust the pasted line so that it is relative to the location of the .gitignore file

Additional info: There is a ".gitignore" plugin available for IntelliJ which adds a "Add to .gitignore" item to the popup menu when you right-click a file. It works like a charm.

To install the plugin, go to "Settings -> Plugins", click on "Browse repositories..." and search for ".ignore".

25

Intellij had .ignore plugin to support this. https://plugins.jetbrains.com/plugin/7495?pr=idea

After you install the plugin, you right click on the project and select new -> .ignore file -> .gitignore file (Git) enter image description here

Then, select the type of project you have to generate a template and click Generateenter image description here

6

You can create file .gitignore and then Idea will suggest you install plugin

2

I'm using intelliJ 15 community edition and I'm able to right click a file and select 'add to .gitignore'

1

Here is the screen print showing the options to ignore the file or folder after the installation of the .ignore plugin. The generated file name would be .gitignore enter image description here

  • How is this answer to a 4-year-old question helpful when there are already several working solutions to this question, all of which are a few years old? When posting answers to questions, make sure your answer is helpful and relevant. – Joel Nov 4 '18 at 22:08
  • The screen print is just an addition to the answers listed above. Sure, Thanks! – TechPassionate Nov 4 '18 at 22:30
0

right click on the project create a file with name .ignore, then you can see that file opened.

at the right top of the file you can see install plugins or else you can install using plugins(plugin name - .ignore).

Now when ever you give a right click on the file or project you can see the option call add to .ignore