Reputation: 7752
I've started working on a project and I've added .idea/*
to the .gitignore file, but it still show's up.
So I thought the file must be in the git cache so I ran git rm --cached filename
, although it does not seems to work as it actually removes the file when I merge the branch, you can see my git commands below.
I recently started developing on a macbook pro, before I was working on ubuntu and I never had this issue. Perhaps it has something to do with my git
setup.
This has happened before on another project, that time when I ran git rm --cached .
it actually removed most of the project files from the file system.
$ (786-rwd) git status
On branch 786-rwd
Your branch is up-to-date with 'origin/786-rwd'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: .idea/misc.xml
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: .gitignore
modified: .idea/modules.xml
modified: .idea/www.project.dev.iml
modified: app/design/frontend/bootstrapped/rwd/template/prog/bund.phtml
Untracked files:
(use "git add <file>..." to include in what will be committed)
skin/frontend/bootstrapped/rwd/sass/_cms-pages.scss
holy in ~/ubuntu_1404/httpdocs/porject
$ (786-rwd) git rm --cached .idea/modules.xml
rm '.idea/modules.xml'
holy in ~/ubuntu_1404/httpdocs/porject
$ (786-rwd) git rm --cached .idea/www.project.dev.iml
rm '.idea/www.project.dev.iml'
$ (786-rwd) git status
On branch 786-rwd
Your branch is up-to-date with 'origin/786-rwd'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: .idea/misc.xml
deleted: .idea/modules.xml
deleted: .idea/www.project.dev.iml
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: app/design/frontend/bootstrapped/rwd/template/prog/bund.phtml
Untracked files:
(use "git add <file>..." to include in what will be committed)
skin/frontend/bootstrapped/rwd/sass/_cms-pages.scss
holy in ~/ubuntu_1404/httpdocs/porject
$ (786-rwd) ls .idea/
./ .name deployment.xml encodings.xml scopes/ workspace.xml
../ copyright/ dictionaries/ modules.xml vcs.xml www.project.dev.iml
$ (786-rwd) git add .
holy in ~/ubuntu_1404/httpdocs/project
$ (786-rwd) git commit -m 'theming & cleaned up git'
[786-rwd 8aa5ba8] theming & cleaned up git
5 files changed, 24 deletions(-)
delete mode 100644 .idea/misc.xml
delete mode 100644 .idea/modules.xml
delete mode 100644 .idea/www.project.dev.iml
create mode 100644 skin/frontend/bootstrapped/rwd/sass/_cms-pages.scss
holy in ~/ubuntu_1404/httpdocs/project
$ (786-rwd) git status
On branch 786-rwd
Your branch is ahead of 'origin/786-rwd' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working directory clean
holy in ~/ubuntu_1404/httpdocs/project
$ (786-rwd) git checkout -b test-branch origin/prod
Branch test-branch set up to track remote branch prod from origin.
Switched to a new branch 'test-branch'
holy in ~/ubuntu_1404/httpdocs/project
$ (test-branch) git merge --no-ff 786-rwd
Auto-merging app/design/frontend/bootstrapped/mobile/template/program/results.phtml
Auto-merging app/design/frontend/bootstrapped/default/template/page/html/header.phtml
Removing .idea/www.project.dev.iml
Removing .idea/modules.xml
Removing .idea/misc.xml
Merge made by the 'recursive' strategy.
.gitignore | 6 +-
.idea/misc.xml | 5 -
.idea/modules.xml | 9 -
.idea/www.project.dev.iml | 9 -
app/design/frontend/bootstrapped/default/layout/local.xml | 66 ++++
$ (test-branch) ls .idea/
./ ../ .name copyright/ deployment.xml dictionaries/ encodings.xml scopes/ vcs.xml workspace.xml
Upvotes: 1
Views: 8685
Reputation: 265595
rm --cached
will mark a file as deleted in the staging area. Next time you commit, the delete will be recorded in the repository's history.
If you then merge this commit to another branch, the file is removed from disk (because Git merges your branches and then checks out the resulting tree).
Upvotes: 3