Changes between Version 39 and Version 40 of WorkingConventions/Git


Ignore:
Timestamp:
Sep 13, 2013 3:58:04 AM (22 months ago)
Author:
thoughtpolice
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WorkingConventions/Git

    v39 v40  
    124124=== Using the reflog === 
    125125 
    126 Eventually when working in the repository, you'll invariably do something on accident that will delete work. If you have never committed the changes, then you're out of luck (commit often, commit early - even locally!) But have you ever done something like: 
     126Eventually when working in the repository, you'll invariably do something on accident that will delete work. Or maybe not delete your work - perhaps you simply want to "undo that thing you just did a minute ago". If you have never committed the changes, then you're out of luck (commit often, commit early - even locally!) But have you ever done something like: 
    127127 * Accidentally lost a commit, by deleting a branch? 
    128128 * Accidentally lost a commit through rebasing? 
     
    130130 * Accidentally overwrote a branch with dangerous operation, like `git push --force`? 
    131131 
    132 '''The reflog can save you from all of these, and more'''. In short, the reflog ''is a log that records every modification which Git tracks''. To understand that, first understand this: despite its appearance, the Git data model has a core tenant: ''it is immutable - data is never deleted, only new copies can be made'' (the only exception is when garbage collection deletes nodes which have no outstanding references - much like our own GC!) Not even a rebase - which can rewrite the history - can actually delete old data. 
     132While you may think all hope is lost, '''the reflog can save you from all of these, and more'''. In short, the reflog ''is a log that records every modification which Git tracks''. To understand that, first understand this: despite its appearance, the Git data model has a core tenant: ''it is immutable - data is never deleted, only new copies can be made'' (the only exception is when garbage collection deletes nodes which have no outstanding references - much like our own GC!) Not even a rebase - which can rewrite the history - can actually delete old data. 
    133133  
    134134Second, we need to understand an '''important part of `git checkout`''': the purpose of `checkout` is ''not'' to switch branches. Checkout, roughly speaking, '''allows you to check out your tree to any state, revision, or copy in the history'''. You don't have to checkout to a branch: you can checkout to a commit from 3 weeks ago, a commit that ''does not exist on a branch'', or a completely empty branch with nothing in common. You can checkout the entire tree, or you could checkout an individual file, or a single directory. The point being: '''checkout takes you to a state in the history.'''