K
K
krlljs2014-05-20 04:43:33
git
krlljs, 2014-05-20 04:43:33

An unnecessary file accidentally got into the remote git repository, how to delete it?

An unneeded file accidentally got into the remote git repository. The fact is that, due to my inexperience, I renamed the demo.sqlite file to db.sqlite. Now two identical files with different names are stored in the remote repository. How to delete? How to avoid such inexperience? We need a proper hack for such a case.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2014-05-20
@krlljs

How to delete?

Depending on whether you want the file to remain in history or not:
git rm -f <имя файла>
git commit
git push
-- remove from HEAD but leave in history
git rebase -i <ревизия в которой файл был добавлен>~1
<пометить самый первый коммит для редактирования заменив peek на e>
git rm -f <имя файла>
git commit --amend
git rebase --continue
git push
-- delete from history completely. If the addition was in the last commit, then the git rebase commands can be omitted.

V
Vlad Zhivotnev, 2014-05-20
@inkvizitor68sl

Avoid like this:
Check out the turnip to a clean directory, do a git rm on an unnecessary file, commit, push - this will be the fastest.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question