Comment on page
Find changes since last commit
After you write a bunch of code and save it, you sometimes can't perfectly remember the details of all the things you changed. The syntax for comparing what you saved to what you committed in Git is
git difftool <filename>.
Skip Steps 1, 2, & 3 if you are using your own code.
- 1.Make a new folder, start a repository there, and open an editor
mkdir te && cd te && git init && nano streets.txt
- 2.Save the file in your editor. Then commit that.
git commit -m "First commit."
- 3.Now that you have a file and are in a repository, go into your editor and add some lines. Save the file but don't commit it.
- 4.Briefly glance at the terminal way to see your saved code vs. your committed code:
git diff streets.txt
- 5.Now see the same thing in Beyond Compare! Way better:
git difftool streets.txt
- 6.Finish by writing your commit message:
git -m "Capitalize all. Specify South and Hills. Add four streets."
What we just diffed was the Working Tree vs the Commited Repository
Image by Freek Dijkstra
Another way to use difftool is to always start the day with it.
The Changelog's Adam Stacoviak says his favorite trick is to end the day by saving files to his index but not committing them. That way in the morning he is forced to read his diff, and then write his commit. This morning ritual reintroduces him to what he was thinking at yesterday's quitting time.