M
M
Makar Gerasimov2016-08-12 11:20:24
git
Makar Gerasimov, 2016-08-12 11:20:24

How to remove a file from the index?

Good afternoon, please tell me what I'm doing wrong.
I have a prod, they rolled a git with the default master branch (git add . ; git commit -m 'init'), then cloned it to a test server, created a develop branch there and created a gitignor + added config files there. Then my actions: I apply rm to all gitignor files (I remove them from the index)

git rm --cached `git ls-files -i --exclude-from=.gitignore`

In the git status it says that the files have been deleted. Then I fix the whole thing with a commit.
And it seems like everything is fine, they are no longer tracked, etc., but as soon as I merge the master branch and the develop git determines from the commit that my configs should be taken to hell. And everything collapses...
Are there any options? Except git cherrypick F^..E

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yaolegol, 2019-05-03
@yaolegol

git filter-branch --force (so that the directory is not removed from the hard drive)
git filter-branch --tree-filter "rm -rf PATH" HEAD
where PATH is the path to the file/folder
How do I remove a directory in Git?
https://help.github.com/en/articles/removing-sensi...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question