M
M
mmjurov2014-01-28 10:54:38
git
mmjurov, 2014-01-28 10:54:38

Deleting files from a Git repository?

There is the following problem. Googling didn't turn up much.
There are develop and production git repositories, and between them there is a bare repository. The working copy of the application contains many more files than you need to keep in the repository. At the same time, the repository obviously contains files that are unnecessary for it, which, in the course of work, must be found and removed from the repository (but not from the working copy). It would seem that you need to use git rm --cached to remove files from control, add them to gitignore and that's it.
If you run git rm --cached on the dev repository, then the files will indeed be removed from the index, while remaining in the local working copy. However, after pushing them to the bare repository and a subsequent pull to production (or any other repository), these files, if present, will be removed from both the repository and the working copy.
The question is, can this be avoided? You need to be able to delete files from the repository, leaving them both in your working copy and in everyone else.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
Oleg, 2014-01-28
@mmjurov

Did you watch it? git-scm.com/book/ru/%D0%9E%D1%81%D0%BD%D0%BE%D0%B2...
lezhnevs.ru/git/udalenie-papki-iz-repozitariya

A
akashtrih, 2014-01-28
@akashtrih

There is no way to avoid deleting files in other repositories.
Alternatively, create a new repository with .gitignore already properly configured.
Or manually recreate the remote file in each remote repository after doing a pull.

D
domgroup, 2016-02-08
@domgroup

Add to .gitignore and remove with --cached option with
git rm --cached /path/to/file

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question