Wednesday 13 March 2024

The Git & Github Bootcamp Part 4- Master on essentials and the tricky bits: rebasing, squashing, stashing, reflogs, blobs, trees, & more!


Undoing Changes & Time Traveling

Checking Out Old Commits

To review or restore your project at a specific point in history:

git checkout <commit-hash>

This moves HEAD to point to the specified commit. Remember, this puts your repository in a “detached HEAD” state, where you’re no longer on a branch.

Re-Attaching Our Detached HEAD!

If you find yourself in a detached HEAD state and want to return to the latest commit on your current branch:

git switch -

Or, if you wish to keep changes from the detached HEAD state, create a new branch from it:

git switch -c new-branch-name
Read more »

Labels: