Disaster Recovery with Git
We’ve defined a commit as a snapshot of our entire project, but if you ask Git, it doesn’t seem to see things that way: Git is assuming that most of our project does not change in any given commit, so showing only the differences will be more useful. Almost all the time, that’s true. But we can also use Git to show us the entire state of the repository at a particular commit, not just the differences. We can ask Git to show us what was in a particular file at a particular commit by typing a colon : after the commit ID and specifying a path to that file: We can also use this command to show the contents of a particular folder at a given commit by specifying a path to that folder. Notably, we can show the state of the entire repo at a given commit by typing nothing after the colon: As the empty filepath corresponds to the root directory in the repo and thus shows all the files in the repo. Using git show is one of the simplest ways you can use Git to recover from a disaster: ask Git to g
Disaster Recovery with Git Disaster Recovery with Git Objectives Understand how to view and retrieve old versions from Git using Git commands Practice using Git to recover old versions of code Why do commits look like diffs? We’ve defined a commit as a snapshot of our entire project, but if you ask Git, it doesn’t seem to see things that way: $ git show 1255f4e commit 1255f4e4a5836501c022deb337fda3f8800b02e4 Author: Max Goldman <maxg@mit.edu> Date: Mon Sep 14 14:58:40 2015 -0400 Change the greeting diff --git a/hello.txt b/hello.txt index c1106ab..3462165 100644 --- a/hello.txt +++ b/hello.txt
Explore this link on the map →related reading
- Git - user-manual Documentationgit-scm.com
- OMBD#21: Master Git Diff With These Not-So-Known Commands | by Jon Portella | ITNEXTjportella93.medium.com
- Version Control with Gitweb.mit.edu
- Reading 5: Version Controlweb.mit.edu
- What is a git "Snapshot"? - Stack Overflowstackoverflow.com
- Version Control (Git) · Missing Semestermissing.csail.mit.edu
- The Myers diff algorithm: part 1 – The If Worksblog.jcoglan.com
- How Git works: A complete guide to branches, merges, and collaborationdeveloper.ibm.com
- Oh Shit, Git!?!ohshitgit.com
- llm-wiki · GitHubgist.github.com
- Unified Versus Split Diffmatklad.github.io
- GitHub - jesseduffield/lazygit: simple terminal UI for git commands · GitHubgithub.com