-
Notifications
You must be signed in to change notification settings - Fork 15
Revert the local copy of a repository to the current version fo the code on the cloud
This is a specific example of how we can change the status of the code locally to represent the code on the cloud (upstream master.
Scenario: Let's say we have an issue with the local version of the repository. Something is failing. We do not know whether the latest changes in the local repository are generating this problem. This repository was not yet pushed and pulled into the master on the cloud. So we can checkout (download) whatever is on the cloud and use that code to see if we broke anything with out latest changes.
$git checkout upstream/master -b upstream_master_test
The previous command created a new local branch of the repository. The option '-b' creates the new branch with the given name. The 'checkout' command indicates which code will be in the repository. In this case the one from the cloud (upstream/master).
Once the code has been tested you will want to revert back to your local repository. To do so:
$git checkout master
To make sure the command worked try:
$git branch
You should see:
* master upstream_master_test
The star (8) means that is the branch where you are sitting.
To delete the temporary test branch we created above, do the following:
$git branch -d upstream_master_test Deleted branch upstream_master_test (was 9193513).
Done, We tried the code from the could and now we are back at the beginning.