How do I restore a deleted, source controlled file from SimulinkProject?

6 views (last 30 days)
I deleted a source controlled file from my simulinkproject but I changed my mind and want it back. How can I do that from Simulinkproject?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 2 Mar 2021
Edited: MathWorks Support Team on 2 Mar 2021
If you did not commit after deleting, you can restore the file by selecting "Revert to HEAD" in the Manage Branches window.
If you committed after deleting the file the process is more complicated.​ The process is to find the commit before the one where your file got deleted, and revert to that. Generally, to make this easier, it's best practice to commit often and note in the commit log whenever you delete or add a file. 
See also our documentation page here: 

To Retrieve a Deleted File From SVN

Click the "Revert Project" button.
In the window that pops up, find the revision where your file was deleted. Either the log messages or the "Modified Files" section should list what files are deleted in each revision.
Select the revision before the one where your file was deleted (in the above example that's revision 2). Then select "Revert". Your file is now available.

To Retrieve a Deleted File From git

1) Use the "Manage Branches" tool to see the log messages:
2) Find the commit before the one where the file was deleted, then select it and note the commit revision number:
3) Open up a git shell, in Windows with command line git by right clicking the folder in explorer and selecting "Git Bash", or in Unix by opening a terminal and changing directory to your sandbox folder.Run the command:
git checkout REVISION_NUMBER FILENAME
where REVISION_NUMBER is the revision number found in step 2, and FILENAME is the name of the file that got deleted.

More Answers (0)

Categories

Find more on Source Control Integration in Help Center and File Exchange

Products


Release

R2014a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!