reset() public method

Reset current HEAD to the specified state.
public reset ( ) : GitWorkingCopy
return GitWorkingCopy
示例#1
0
 public function deploy()
 {
     // Create the wrapper.
     $wrapper = new GitWrapper();
     $wrapper->streamOutput();
     // Iterate through each project.
     foreach ($this->projects as $name => $project) {
         // Check out all branches.
         foreach ($project['branches'] as $branch => $destination) {
             // Build our git interface.
             $git = null;
             if (!is_dir($destination)) {
                 $git = $wrapper->cloneRepository($project['repo'], $destination);
             } else {
                 $git = new GitWorkingCopy($wrapper, $destination);
             }
             // Fetch the latest.
             $git->fetch('origin');
             // Checkout the desired branch.
             $git->checkout($branch, array('force' => true));
             // Reset any local changes.
             $git->reset(array('hard' => true));
             // Pull the latest from the branch.
             $git->pull('origin', $branch, array('force' => true));
         }
     }
 }
示例#2
0
 /**
  * @param $branch
  * @param bool $force
  * @throws \Exception
  * @throws \GitWrapper\GitException
  */
 public function checkoutAndPullBranch($branch, $force = false)
 {
     try {
         if ($force) {
             $this->git->reset('--hard');
         }
         $this->precheck();
         $this->git->fetch()->checkout($branch)->pull();
         return $this->getCommitHash();
     } catch (GitException $e) {
         throw $e;
     }
 }