I'm still trying to fully learn Git, but after searching I'm still a bit confused. I removed the file from the Git repository using git rm --cached and the file remains locally. Upon pushing to the remote git repository and pulling it on the developmental server, the file that I removed is deleted. Could someone please suggest how to fix this?
-
1fix what? what are you expectingXiaotian Pei– Xiaotian Pei2015-07-02 17:05:17 +00:00Commented Jul 2, 2015 at 17:05
-
Related: stackoverflow.com/q/1139762/1157054Ajedi32– Ajedi322015-07-02 17:32:43 +00:00Commented Jul 2, 2015 at 17:32
-
Do you want to delete those files?mayo– mayo2015-07-02 18:12:53 +00:00Commented Jul 2, 2015 at 18:12
-
To make it clear, I'm trying to remove my wp-config.php from my repository as it is different on my computer and my development server. I want to have 2 different copies of the file, but when I ran git rm --cached, it kept a copy on my computer, but when I pulled to my server, the file was deleted.SVAN– SVAN2015-07-02 18:28:09 +00:00Commented Jul 2, 2015 at 18:28
Add a comment
|
2 Answers
There are 3 areas you need to consider: the repository, the staging area and the workspace.
- git rm removes from the staging area and the workspace
- git rm --cached removes from the staging area only. It only gets removed from the workspace when you commit.
The file still remains in the repository. If you get a version of the repository before the file was removed, you will get the file back.
2 Comments
ikrabbe
To escalate the example, you can erase the file from the whole history:
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch FILES" HEAD. Be careful with this!SVAN
To make it clear, I'm trying to remove my wp-config.php from my repository as it is different on my computer and my development server. I want to have 2 different copies of the file, but when I ran git rm --cached, it kept a copy on my computer, but when I pulled to my server, the file was deleted.