using System.Diagnostics;
using UnityEditor;
using Debug = UnityEngine.Debug;public class GitUtility
{/// <summary>/// 获取环境git.ext的环境变量路径/// </summary>private static string strEnvironmentVariable {get{string strPath = System.Environment.GetEnvironmentVariable("Path");if (string.IsNullOrEmpty(strPath)){Debug.LogWarning(">>>>>strEnvironmentVariable: enviromentVariable is not config!!!!");return null;}string[] strResults = strPath.Split(';');for (int i = 0; i < strResults.Length; i++){if (!strResults[i].Contains(@"Git\cmd"))continue;strPath = strResults[i];}return strPath;}}/// <summary>/// /// git工作路径/// </summary>private static string m_strWorkingDir;public static string strWorkingDir{get { return m_strWorkingDir; }set { m_strWorkingDir = value; }}/// <summary>/// 执行git指令/// </summary>public static void ExcuteGitCommand(string strCommnad, DataReceivedEventHandler call){string strGitPath = System.IO.Path.Combine(strEnvironmentVariable, "git.exe");if(string.IsNullOrEmpty(strGitPath)){Debug.LogWarning(">>>>>strEnvironmentVariable: enviromentVariable is not config!!!!");return;}Process p = new Process();p.StartInfo.FileName = strGitPath;p.StartInfo.Arguments = strCommnad;p.StartInfo.CreateNoWindow = true;p.StartInfo.UseShellExecute = false;p.StartInfo.RedirectStandardOutput = true;p.StartInfo.WorkingDirectory = strWorkingDir;p.OutputDataReceived += call;p.OutputDataReceived -= OnOutputDataReceived;p.OutputDataReceived += OnOutputDataReceived;p.Start();p.BeginOutputReadLine();p.WaitForExit();}/// <summary>/// 输出git指令执行结果/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private static void OnOutputDataReceived(object sender, DataReceivedEventArgs e){if (null == e || string.IsNullOrEmpty(e.Data)){Debug.Log(">>>>>>Git command error!!!!!");return;}Debug.Log(e.Data);}
}

c# 操作git指令相关推荐

  1. Git指令2 - 操作分支

    Git指令2 - 操作分支 Git简单基本操作指令集合 Git分支 分支作用: 多人协作开发,防止相互干扰,提高协同开发的体验 初始化本地仓库时,默认创建了master主分支 主分支:作用 用来保存和 ...

  2. Git版本管理工具超详细(下载、安装、远程仓库的搭建、git指令)

    目录 01_Git概述 02_GIT相关概念(掌握) 03_Git下载与安装 04_Git本地操作-初始化工作区 05_Git本地操作-add与commit 06_Git本地操作-差异比较 07_Gi ...

  3. as使用Git指令远程或者本地创库代码合并

    如果在as已经打开一个fork指定分支的项目,想合并所fork的主创库指定分支,如果在gitlab中请求合并出现冲突,会显示一个merge locally按钮,点击改按钮弹出一下弹窗: 可以在as的T ...

  4. 我目前在工作中常用的git指令

    先讲一下:这篇文章适合有一点点git基础并且电脑安装好了git,刚刚到职场有点蒙蔽的的同学看,因为我就是这么一个个坑爬过来的,然后推荐廖雪峰的git教程,个人觉得不错,我自己还没看完,大家共勉 git ...

  5. git 指令学习和熟悉——learn git branching练习笔记

    前言: 在工作中我们用到git系列工具机会很多,也常常需要熟悉git 相关指令,那怎样才能高效学习git指令呢?我们可以通过小游戏learn git branching和菜鸟教程完成学习. 小游戏链接 ...

  6. 如何使用 Python 操作 Git 代码?GitPython 入门介绍

    点击上方"视学算法",选择"置顶或者星标" 第一时间阅读精彩文章! 作者:匿蟒 链接:https://note.qidong.name/2018/01/gitp ...

  7. 项目中常用的git指令

    1.新建一个本地分支并切换到新建的那个分支: git checkout -b (新分支名) 2.从一个分支切换到另一个分支: git checkout 分支名 3.将代码恢复到最近的一次commit ...

  8. vscode:解决操作git总让输入用户名及密码问题

    vscode:解决操作git总让输入用户名及密码问题 参考文章: (1)vscode:解决操作git总让输入用户名及密码问题 (2)https://www.cnblogs.com/finalanddi ...

  9. Python操作git

    一.Git版本管理 很多公司在使用git的tag进行版本的管理. git tag -n 查看本地Tag git tag -l 'v1.4.2.*' 查看本地Tag,模糊匹配 git show v1.0 ...

最新文章

  1. 独家 | CIKM AnalytiCup 2017冠军团队获胜经验分享(附PPT视频)
  2. Mastering the Java CLASSPATH
  3. 《MANAGING THE DEVELOPMENT OF LARGE SOFTWARE SYSTEMS》总结
  4. luogu4389 付公主的背包
  5. DRUID连接池的简单使用
  6. 前端学习(1666):前端系列实战课程之仿造qq发送消息思路
  7. JVM-内存溢出场景模拟
  8. mask rcnn算法分析_实例分割综述(单阶段/两阶段/实时分割算法汇总)
  9. 问题 B: 编写函数:Swap (I) (Append Code)
  10. matplotlib绘制李萨如图(三) 静态3D李萨如图
  11. 掘金往期沸点神评合集(别审过)
  12. 王天官系古盐山县(今孟村县王帽圈)人
  13. springboot2.0+springDataJPA报错Could not obtain identifier
  14. 面试必备:虾皮服务端15连问
  15. 通过存储控制器访问外设
  16. OpenCV python 彩色图片的三通道
  17. 时间复杂度(超详解+例题)
  18. 作为一名新晋码农,以下是我个人的工作心得,希望能帮到刚步入编程殿堂和使用vue-cli和ant-design-vue UI组件库的童鞋们
  19. Phpstudy的安装及使用(web)
  20. 大量短视频怎么批量添加个人logo呢?

热门文章

  1. Mysql数据库备份和恢复总结
  2. v-html 解析并插入 html 标签
  3. Android Studio:Android Studio安装Genymotion插件
  4. currency symobl
  5. 直播手机支架上的灯和多机位的作用
  6. 打造自己的图像识别模型2——使用 TensorFlow Slim 微调模型
  7. MyBatis 源码分析 - 配置文件解析过程
  8. 纪念一位老友,记录一段往事
  9. Java基础学习笔记(十六)—— Sream流
  10. Linux adduser