Skip to content
  • Linus Torvalds's avatar
    Add 'merge' mode to 'git reset' · 9e8eceab
    Linus Torvalds authored and Junio C Hamano's avatar Junio C Hamano committed
    We have always had a nice way to reset a working tree to another state
    while carrying our changes around: "git read-tree -u -m". Yes, it fails if
    the target tree is different in the paths that are dirty in the working
    tree, but this is how we used to switch branches in "git checkout", and it
    worked fine.
    
    However, perhaps exactly _because_ we've supported this from very early
    on, another low-level command, namely "git reset", never did.
    
    But as time went on, 'git reset' remains as a very common command, while
    'git read-tree' is now a very odd and low-level plumbing thing that nobody
    sane should ever use, because it only makes sense together with other
    operations like either switching branches or just rewriting HEAD.
    
    Which means that we have effectively lost the ability to do something very
    common: jump to another point in time without always dropping all our
    dirty state.
    
    So add this kind of mode to "git reset", and since it merges your changes
    to what you are resetting to...
    9e8eceab