在 當前倉庫根目錄下執(zhí)行命令
git submodule add https://github.com/xxx/child.git
檢查倉庫狀態(tài)
git status
更新子庫
git submodule update --remote
下拉父倉庫Git并保住子庫也更新
git pull --recurse-submodules文章來源:http://www.zghlxwxcb.cn/news/detail-628746.html
推薦使用 Githubdesktop工具
這樣你可以更清楚的看到自己子庫關聯(lián)狀態(tài)文章來源地址http://www.zghlxwxcb.cn/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模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!