Reset() public method

public Reset ( ) : void
return void
Exemplo n.º 1
0
        public void Branch()
        {
            //Get the current branch
            var branch = repo.CurrentBranch;

            Console.WriteLine("Current branch is " + branch.Name);

            //Another way to get the current branch
            Branch head = repo.Head;

            // check if head == master
            Debug.Assert(head.Name == "master");

            //Get master branch
            var master = new Branch(repo, "master");

            Debug.Assert(master == repo.Get <Branch>("master"));

            //Get the abbreviated hash of the last commit on master
            Console.WriteLine(master.CurrentCommit.ShortHash);

            //Create a new branch
            var b = GitSharp.Branch.Create(repo, "foo");

            // Switching to our new branch
            b.Checkout();

            //Check if foo is current branch
            Debug.Assert(b.IsCurrent);

            //Reset the branch to a previous commit (hard or soft or mixed)
            master.Reset("HEAD^", ResetBehavior.Hard);
            master.Reset("49322bb17d3acc9146f98c97d078513228bbf3c0", ResetBehavior.Soft);
            master.Reset("master", ResetBehavior.Mixed);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Switch to the given branch
        /// </summary>
        /// <param name="branch"></param>
        public static void SwitchTo(Branch branch)
        {
            var db = branch._repo._internal_repo;

            db.WriteSymref(GitSharp.Core.Constants.HEAD, branch.Name);
            branch.Reset(ResetBehavior.Hard);
        }
Exemplo n.º 3
0
        public void Branch()
        {
            //Get the current branch
            var branch = repo.CurrentBranch;
            Console.WriteLine("Current branch is " + branch.Name);

            //Another way to get the current branch
            Branch head = repo.Head;

            // check if head == master
            Debug.Assert(head.Name == "master");

            //Get master branch
            var master = new Branch(repo, "master");
            Debug.Assert(master == repo.Get<Branch>("master"));

            //Get the abbreviated hash of the last commit on master
            Console.WriteLine(master.CurrentCommit.ShortHash);

            //Create a new branch
            var b = GitSharp.Branch.Create(repo, "foo");

            // Switching to our new branch
            b.Checkout();

            //Check if foo is current branch
            Debug.Assert(b.IsCurrent);

            //Reset the branch to a previous commit (hard or soft or mixed)
            master.Reset("HEAD^", ResetBehavior.Hard);
            master.Reset("49322bb17d3acc9146f98c97d078513228bbf3c0", ResetBehavior.Soft);
            master.Reset("master", ResetBehavior.Mixed);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Switch to the given branch
 /// </summary>
 /// <param name="branch"></param>
 public static void SwitchTo(Branch branch)
 {
     var db = branch._repo._internal_repo;
     db.WriteSymref(GitSharp.Core.Constants.HEAD, branch.Name);
     branch.Reset(ResetBehavior.Hard);
 }