Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bzr: Restoring a deleted file after some commits with bazaar

I'd like to know if it is possible to restore a removed file from an older revision (a clean way to do it)

I've renamed a file for some tests, than I commited all my work (and I forgot to rename the file) and did a lot of other commits... When I realised, it was too late...

Regards, Ayman

like image 329
Ayman Khamouma Avatar asked Oct 26 '09 18:10

Ayman Khamouma


2 Answers

The easiest way is to simply use bzr revert with a revision number before the file was deleted:

bzr revert -rX path/to/file
bzr commit -m 'Bringing path/to/file back'

You don't need to merge anything.

like image 95
Lukáš Lalinský Avatar answered Oct 10 '22 09:10

Lukáš Lalinský


If you know revision number when you removed that file (you can inspect history with bzr log -v) then you can resurrect that file with merge command. So for file foo and revision number N you need to run command:

bzr merge foo -r N..N-1

E.g. for revision 287:

bzr merge foo -r 287..286

This command will restore your file as in revision 287. You need to commit this change and you done.

like image 45
bialix Avatar answered Oct 10 '22 09:10

bialix