I must be missing something, because I've read all the doc for reset, revert, etc., but I can't work out how to get the contents of my index into the working tree. (I copied the .git
folder from elsewhere and just want to do a 'get latest').
git commit -m'for now'
git checkout -f
git reset --soft HEAD~
checkout
step is necessary here because your repository doesn't have a working tree (i.e. it consists of nothing but the .git/ directory), and so the checkout will arrange for the working tree to reflect HEAD
.HEAD
reference to its parent, thus effectively discarding the last commit. The commit is still in the DAG, pointed at by the reflog should you ever care to look at it, but its not part of your branch's timeline anymore. This step is a soft reset, which means that Git places back the changes of that last commit in the index, and it doesn't change the working tree from how it looked when HEAD
pointed at that last commit we committed. The commit is not part of your history but the changes are still there in the working tree and in the stage.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With