How to delete a file from the repository locally and remotely, but keeping it locally?

Git how to delete a file from the repository, saving locally and delete from the remote repository (was previously added)?

A long time was mistakenly added the file to the local repository .bashgui.xml
was git commit and git pull remote master
deleted from the local repository to save the file - git rm --cached .bashgui.xml
but in the remote repository after git pull remote master file

1. how to delete from remote repository?

2. There is a file which contains the application configuration with passwords, is there a way to save the file to the repository but with the removal/substitution of passwords?

October 3rd 19 at 01:50
3 answers
October 3rd 19 at 01:52
Solution

Question inaccurate. If in a remote repository, got the password file, and this repository is accessed by other people, the first thing you need to do is to change all passwords that were published. Then file copy in a safe place and remove the working copy, comitia, add to gitignore, again commits. Doing a git push. The file can be returned back.

If access is private, or fundamentally want to remove information from the repository, use the commands modify existing commits git rebase --interactive` (more in Change commits in Git, under "Change is NOT the latest commit") and the forced rewriting of history `git push origin +master` (git push -f).

On the second question. Have the following equipment: added to the repository config file.ini.example with a full set of settings, only with fake passwords. Added gitignore in config.ini. You can then safely copy the config.ini.example in the config.ini, make the desired changes to work.

October 3rd 19 at 01:54

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

October 3rd 19 at 01:56

The easiest option is to remove a remote repository and push again, if you work alone.

Find more questions by tags Git