首页 > 代码库 > git for c#,文件更名

git for c#,文件更名

        private static void pushRename()
        {
            string wkDir = @"E:\DotNet2010\单位工程\Git.Client\lib2Test\ConsoleApplication1\bin\Debug\D2Git\.git";
            using (var repo = new Repository(wkDir))
            {
                //rename one.txt two.txt
                //此处设置断点,重命名目录下的文件名 one.txt->1.txt,two.txt->2.txt
                var opts = new StatusOptions
                {
                    DetectRenamesInIndex = true,
                    DetectRenamesInWorkDir = true,
                };


                RepositoryStatus status = repo.Index.RetrieveStatus(opts);
                repo.Index.Stage("one.txt");
                repo.Index.Stage("1.txt");

                repo.Index.Stage("two.txt");
                repo.Index.Stage("2.txt");
                status = repo.Index.RetrieveStatus(opts);

                //commit...
                //push...
            }

            Console.Read();
        }
转载请注明出处:blog.csdn.net/javasuki