在 当前仓库根目录下执行命令
git submodule add https://github.com/xxx/child.git
检查仓库状态
git status
更新子库
git submodule update --remote
下拉父仓库Git并保住子库也更新
git pull --recurse-submodules文章来源:https://www.toymoban.com/news/detail-628746.html
推荐使用 Githubdesktop工具
这样你可以更清楚的看到自己子库关联状态
文章来源地址https://www.toymoban.com/news/detail-628746.html
在Unity本使用脚本调用Git
public static void NewGitCommand( string arguments, string WorkingDirectory = "./" )
{
string gitPath = "git";
ProcessStartInfo startInfo = new ProcessStartInfo( gitPath, arguments )
{
WindowStyle = ProcessWindowStyle.Hidden,
UseShellExecute = false,
ErrorDialog = false,
CreateNoWindow = true,
RedirectStandardError = true,
RedirectStandardInput = true,
RedirectStandardOutput = true,
LoadUserProfile = true,
WorkingDirectory = WorkingDirectory
};
var p = new Process { StartInfo = startInfo };
p.OutputDataReceived += new DataReceivedEventHandler( ( object sender, DataReceivedEventArgs eventArgs ) =>
{
if ( !string.IsNullOrEmpty( eventArgs.Data ) )
{
Debug.Log(eventArgs.Data);
}
} );
p.ErrorDataReceived += new DataReceivedEventHandler( ( object sender, DataReceivedEventArgs eventArgs ) =>
{
if ( !string.IsNullOrEmpty( eventArgs.Data ) )
{
Debug.Log( eventArgs.Data );
}
} );
p.Start();
p.BeginOutputReadLine();
p.WaitForExit();
p.Close();
p.Dispose();
}
案例
public static void InitOrUpdateSubmodule()
{
//Log.PINK( "Begin Update Submodule ======>" );
NewGitCommand( "submodule update --init --recursive" );
NewGitCommand( "pull" );
NewGitCommand( "submodule update" );
NewGitCommand( "submodule update --remote" );
AssetDatabase.Refresh();
//Log.PINK( "End Update Submodule ======>" );
}
到了这里,关于Unity Git项目添加子模块的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!