If you supply paths to reset you cannot supply -hard and reset will only change the index version of the supplied paths to the version in the supplied commit (or HEAD if you don't specify a commit). Other forms of reset and commit involve supplying paths. reset will change the current branch to point at the selected commit whereas checkout will leave the current branch alone but will checkout the supplied branch or commit instead. If you current have a branch checked out out there is a crucial different between reset and checkout when you supply an alternative branch or commit. In this case it will reset HEAD and the index to the given commit as well as performing the checkout of the index into the working tree.Īlso, if you supply -hard to reset you can ask reset to overwrite the working tree as well as resetting the index. Once you start adding parameters it is true that there is some overlap.Ĭheckout is usually used with a branch, tag or commit. This is a safety feature to make sure that the "no argument" form isn't destructive: git checkout To get it to actually do anything you would have to use -f to force it to overwrite any local changes. Resets the index to match HEAD, working tree left alone: git resetĬonceptually, this checks out the index into the working tree. In their simplest form, reset resets the index without touching the working tree, while checkout changes the working tree without touching the index.
0 Comments
Leave a Reply. |