Skip to content
Snippets Groups Projects
Commit 99428c14 authored by Daniel McVicker's avatar Daniel McVicker
Browse files

Added 'undoing changes' section

parent 5ca789d6
No related branches found
No related tags found
No related merge requests found
......@@ -706,6 +706,38 @@ dealing with conflicts
Save the log message file, and exit. We now have completed our merge! See what
the log shows.
undoing changes
---------------
When things stop working, sometimes starting over is easier than trying to
find and fix the error. One of the nice features of git is that you can
"go back" to any of your commits. For example, if you want to reset your
repository to the state it was in when you last committed, run:
git reset --hard HEAD
More generally, you can restore your local repository to ANY previous commit.
To do this, find the commit hash of the commit you want to restore (e.g. via
git log) and run:
git reset --hard <hash>
However, since this discards changes to all files in the repository, it's not
ideal if only one or two files are broken, and the rest have changes you
want to keep. Fortunately, git has a way to restore individual files. To
reset file1, run:
git checkout [<commit hash>] -- file1
(Note: the 'commit hash' argument is optional. If you omit it, git will
default to using the previous commit)
IMPORTANT: The ability to restore old versions can be incredibly useful,
but only if you make regular commits. There WILL be a time when you'll need
to reset your repository -- if your last working commit was five minutes
ago, this will be a minor setback; if it was five hours ago, you'll be much
less happy. Remember: commit early, commit often!
gitk
----
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment