Java Reference
In-Depth Information
The output has some gunk at the top and then a few lines from the middle
of , including two marked with plus signs (+). Those are the two
lines that were added. Ah, that's the problem! Adding those lines was a bad
idea; in fact, it would be nice just to scrap everything since the last commit,
and restore this file to how it was before.
If you haven't committed a file yet, you can always get back to the last commit
(like a save point in a game) by typing this:
$ git checkout
Silently but surely, goes back to the way it was. Anything
you typed in since the last commit is gone. Vanished.
So in our case, we can do this:
$ cd src/cowshooter
$ ls
$ git checkout
Now is back to a known, running state. We can even recompile:
$ cd ~/Desktop/code/CowShooter
$ ./
Compiling with javac...
Creating jar file...
Deploying jar to /Users/andy/Desktop/server/plugins...
Completed Successfully.
So, it's easy to throw out bad changes and get back to the last save point.
But what if you committed bad changes a while back, and only noticed the
problem now? You can use the same checkout command, but this time
specify which commit to fetch.
Let's try that now. Go back into and add the bad zombies line
again. But now commit it with this:
$ git commit -a -m 'Added zombie warning'
[master e4ee198] Added zombie warning
1 file changed, 2 insertions(+)
Now let's break it even worse. Find the line that says
private Cow cow;
and delete it. Commit that as well:
$ git commit -a -m 'Deleted variable declaration'
[master 44b39f3] Deleted variable declaration
1 file changed, 3 deletions(-)
Search WWH ::

Custom Search