2

I'm working with one other programmer using Github on an IntelliJ IDEA project. I'm not very experienced with Git and he's not very experienced with programming so we need a simple solution.

This question is not about myself updating the index--it's about whether my partner needs to do something, and if he doesn't will he commit changed .idea files?

I accidentally didn't include the .idea directory in .gitignore when first creating the repository. I've added it now and committed the new .gitignore, and I know that I need to do something else--use git update-index --skip-worktree to stop tracking those files (see .gitignore doesn't stop changes being tracked in files). My question is whether my partner will have to do something similar. I'm sure he will get the new .gitignore when he pulls this commit, but will he also have to run git update-index --skip-worktree?

composerMike
  • 966
  • 1
  • 13
  • 30
  • Possible duplicate of [How to make Git "forget" about a file that was tracked but is now in .gitignore?](https://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore) – phd Feb 05 '19 at 10:04
  • Possible duplicate of [using gitignore to ignore (but not delete) files](https://stackoverflow.com/questions/6317169/using-gitignore-to-ignore-but-not-delete-files) – sergej Feb 06 '19 at 10:14

2 Answers2

1

To stop tracking the .idea directory, do the folowing:

Update the .gitignore:

echo ".idea/" >> .gitignore

Remove the .idea/ directory from the index, leave the working tree files alone:

git rm --cached .idea/

Commit and push:

git add .gitignore
git commit -m "do not track .idea folder"
git push

Now your team-mate will just need to pull this commit.

sergej
  • 17,147
  • 6
  • 52
  • 89
  • From my reading of other posts I believe this will cause git to remove his .idea files, which is not what I want. – composerMike Feb 06 '19 at 06:13
  • @composerMike That's right, I don think there is way to do it without additional steps on the other repo. You team mate could get the folder back with `git checkout -- .idea`, for example. – sergej Feb 06 '19 at 10:20
0

Both of You have to remove this file from index and add to .gitignore or You partner can checkout you solution with your job done.

dunajski
  • 381
  • 3
  • 15