A
A
Alexander Sulimov2013-11-18 11:25:37
git
Alexander Sulimov, 2013-11-18 11:25:37

How to remove a file from both local and remote repository but keeping local?

Git how to remove a file from a repository while keeping it locally and removing it from a remote repository (previously added there)?
A file was added to the local repository a long time ago by mistake - .bashgui.xml
were - git commit and git pull remote master
removed from the local repository with the file saved - git rm --cached .bashgui.xml
but in the remote repository after git pull remote master file remains
1. how to delete from a remote repository?
2. Is there a file that contains the application configuration with passwords, is there a way to save the file to the repository but with the removal / replacement of passwords?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander, 2013-11-18
@AlexandrDP

The question is inaccurate. If a file with passwords has got into the remote repository, and other people have access to this repository, then the first thing to do is change all the passwords that have been published. Then you copy the file to a safe place, delete it in the working copy, commit, add it to gitignore, commit again. Do a git push. The file can be returned.
If only you have access, or if you absolutely want to delete information from the repository, use the commands to change existing commits `git rebase --interactive` (for more details, see Changing commits in Git , section "Changing NOT the last commit") and force rewriting the history `git push origin +master` (git push -f).
On the second question. There is the following technique: the config.ini.example file is added to the repository with a full set of settings, only fake passwords. config.ini is added to gitignore. After that, you can safely copy config.ini.example to config.ini, make the necessary changes, and work.

I
Ivan Panteleev, 2013-11-18
@Yekver

You can try to make a commit to a remote repository, in which this file will be deleted. And then in manual mode, just add it on the local machine and put it on ignore.

N
Nikita Gusakov, 2013-11-18
@hell0w0rd

The easiest option is to remove the remote repository and push again if you are working alone.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question