MATLAB 帮助中心
将文件标记为从 Git 仓库删除
自 R2023b 起
rm(repo,files)
rm(repo,files) 将文件 files 标记为从 Git™ 仓库 repo 删除。rm 函数不会从本地磁盘删除文件。该函数会从 .git 文件夹中删除缓存的文件。
repo
files
rm
.git
示例
全部折叠
创建一个新的 Git 仓库并创建一个仓库对象。
repo = gitinit("newrepo");
创建一个新脚本。
edit newScript.m;
将文件标记为添加并将其提交到仓库。
add(repo,"newScript.m"); commit(repo,message="Add file");
从仓库中删除新文件。
rm(repo,"newScript.m"); commitDetails = commit(repo,message="Remove file")
commitDetails = GitCommit with properties: Message: "Remove file" ID: "7fdae521aafe591738864a386608f41f9bdfa2ee" AuthorName: "username" AuthorEmail: "username@mathworks.com" AuthorDate: 17-Apr-2023 14:53:56 +0000 CommitterName: "username" CommitterEmail: "username@mathworks.com" CommitterDate: 17-Apr-2023 14:53:56 +0000 ParentCommits: "c205f677db61dc94cc5e48a4467410f45e31db4a"]
打开 Times Table App 工程仓库,并创建一个仓库对象。
openExample("matlab/TimesTableProjectExample") repo = gitrepo;
从磁盘删除一个文件。
file = fullfile(pwd,"requirements","TimesTableRequirements.mlx"); delete(file);
从磁盘删除文件不会将其从源代码管理中删除。status 函数将文件报告为 Missing。
status
Missing
repoStatus = status(repo)
repoStatus = 1×1 table Status _____________________ C:\Workspace\TimesTableProjectExample\TimesTableApp\requirements\TimesTableRequirements.mlx Missing
从源代码管理中删除缺失文件。
rm(repo,file);
将删除提交到仓库。
commit(repo,Message="Remove unused file");
有关如何恢复缺失文件的说明,请参阅 discardChanges。
discardChanges
matlab.git.GitRepository
Git 仓库,指定为 matlab.git.GitRepository 对象。
要从 Git 仓库删除的文件,指定为字符串数组、字符向量或字符向量元胞数组。
示例: "myfile.m"
"myfile.m"
数据类型: char | string | cell
char
string
cell
在执行合并时,可以使用 add 或 rm 函数将文件上的冲突标记为已解决。
add
在 R2023b 中推出
gitrepo | gitinit | gitclone | add | commit
gitrepo
gitinit
gitclone
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 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处