MATLAB 帮助中心
放弃 Git 存储库中的更改
自 R2024a 起
discardChanges(repo,files)
discardChanges(repo,files) 放弃 Git™ 存储库 repo 中指定的文件或文件夹 files 中的更改。
repo
files
示例
全部折叠
导航到您的存储库文件夹并创建一个存储库对象。
repo = gitrepo;
放弃存储库中的所有更改。
discardChanges(repo,repo.ModifiedFiles);
打开 Times Table App 工程存储库并创建一个存储库对象。
Times Table App
openExample("matlab/TimesTableProjectExample") repo = gitrepo;
从磁盘删除一个文件。
file = fullfile(pwd,"requirements","TimesTableRequirements.mlx"); delete(file);
从磁盘删除文件不会将其从源代码管理中删除。使用 status 函数显示存储库的状态。文件状态为 Missing。
status
Missing
repoStatus = status(repo)
repoStatus = 2×1 table Status _____________________ C:\Workspace\TimesTableProjectExample\TimesTableApp\requirements\TimesTableRequirements.mlx Missing C:\Workspace\TimesTableProjectExample\TimesTableProjectExample.m NotUnderSourceControl
通过撤销本地删除来还原缺失文件。
discardChanges(repo,file);
matlab.git.GitRepository
Git 存储库,指定为 matlab.git.GitRepository 对象。
要还原的文件或文件夹,指定为字符串数组、字符向量或字符向量元胞数组。如果您指定一个文件夹,该函数会以递归方式放弃对所有已修改文件的更改。
示例: "modifiedFile.m", "my_folder_hierarchy"
"modifiedFile.m"
"my_folder_hierarchy"
数据类型: char | string | cell
char
string
cell
在 R2024a 中推出
gitclone | gitrepo | commit
gitclone
gitrepo
commit
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处