Checkout

If you only want to checkout the code from a specific commit, to bring it back instead of reverting it, you can checkout a commit. This will discard your uncommitted changes and restore the files from the checked out commit to your working tree as unstaged changes. This is usually done when you have committed something to a file a while back, and want to use the changes from another developer, instead.

Caution: If you checkout a specific commit without filenames, the HEAD pointer will be detached! This can have some pretty ugly results, if the Git garbage collection runs and discards further commits: https://git-scm.com/docs/git-checkout#_detached_head.

The next code sample illustrates how to check out a specific commit to reapply old changes:

# Bring code from commit into working copy
git checkout 02fdabc NewScript.ps1

# Commit "old" code
git add .
git commit -m 'Reapplied changes'
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.174.239