How Do I Use Beyond Compare: Introduction to Beyon
  • Forty things about Beyond Compare
  • Acknowledgements
  • Learn Beyond Compare in 5 Minutes
    • Quickstart: open two directories
    • Quickstart: open two files
    • Quickstart: move a file
    • Text Compare: understand the display
    • Downloads
  • Text Compare
    • How to use Beyond Compare for Text Compare
    • In Beyond Compare, what are unimportant differences?
    • Why no word-wrap ??
    • How to use Beyond Compare to confirm 100% replacement
    • Ignore Trivial Differences, Like Timestamps
  • Git
    • How to use Beyond Compare with Git
    • Do a roll-back to peek at your old code
    • Quickstart: Folder Merge
    • Why merge three folders?
    • Beyond Compare Three-Way Folder Merge Symbols Explained
    • How to compare two commits, both old, in Git
    • Git mergetool: merging three files.
    • How to recover an older version of your code with Git and Beyond Compare
    • Peeking under the hood at how Git does its thing
    • Getting better at Git
    • Find changes since last commit
    • Patches
    • How to configure Visual Studio to use Beyond Compare for Version Control
  • Scripts and the Command Line
    • How to use Beyond Compare in the Terminal
    • How to do an automatic backup every day
    • Write a Batch File That Will Start Several Syncs Simultaneously
    • Write a batch file that will start several text compares automatically
    • TL; DR
  • Table Compare
    • Quickstart: open a couple of Excel spreadsheets
    • Example: finding missing items in a pair of spreadsheets
    • Keys
    • Mismatched Columns
    • Longer example, opening .csv files
    • How to remove columns from a spreadsheet
    • Aligned vs Unaligned
    • Example: List of City Trees
  • Sync / Folders
    • Backup your entire computer (Part One)
    • Backup your entire computer (Part Two)
    • Backup, advanced
    • RegEx Examples: Filename Alignment Overide
    • Scan a lot or a little
  • Other
    • Peek
    • Binary
    • Undo
    • Colors
    • How to compare images
    • Report: Text Compare
    • Report: Table Compare
    • Looooonnnnngggg lines...
    • Binary: How to see the 1's and 0's
    • How to write your first script
    • How to find redundant or duplicate files
    • Minor Edge Cases
    • Shortcut Key
    • How to ignore parts of your file
    • Folder System Context Menus
    • About Evan Genest
Powered by GitBook
On this page
  • Compare your current code with an older Git commit
  • How to use Beyond Compare as your Git difftool to look at older code
  • DeBug your current broken code by comparing it with your old working code

Was this helpful?

  1. Git

How to recover an older version of your code with Git and Beyond Compare

PreviousGit mergetool: merging three files.NextPeeking under the hood at how Git does its thing

Last updated 6 years ago

Was this helpful?

Compare your current code with an older Git commit

Git is a safety net. If you commit frequently you can also commit fearlessly: anything you break in your code can be rolled back to a recent commit.

Git tags each old commit with a long hash number. To look at any old commit, you just copy and paste the first dozen digits into your command line syntax.

How to use Beyond Compare as your Git difftool to look at older code

We are going to open up a window that shows my current file on one side and an older commit on the other side.

I'm going to do it wrong twice and then do it correctly.

Wrong. You can leave the file unspecified in your command line arguments. Git may open up the wrong file. Or may open up multiple files.

Better. I have opened up the plain old diff of just my broken code. If your change is more than a line or two, this will be hard to read.

DeBug your current broken code by comparing it with your old working code

You have now opened up a TextCompare session. Use your mouse and instincts to edit your current file on the tree. In this screenshot, it is the panel on the right (notice its address in the top white address bar). Don't edit the old commit on the other side! (The potency of Beyond Compare unfortunately allows you to go back and rewrite your saved snapshots -- very Orwellian!).

Once your editing is finished and you are satisfied, press the save button here and then in the terminal, do a commit, e.g.

git add myfile.txt

git commit -m "Fix bug in code.

Correct. I have used the syntax git difftool -- filename. Instead of diff we say difftool. Assuming we have that we want Git to use Beyond Compare, this will open our files up in BC. Also in Git, the double dash syntax is like a colon, it emphasizes 'do-the-previous-verb-to-the-following-noun'.

previously specified