Reputation: 66541
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').
Upvotes: 4
Views: 2363
Reputation: 18292
git checkout -f HEAD
That will cause all of the files to be forcefully checked out, overwriting what git thinks is currently a deletion. HEAD can also be any reference (branch, commit id, etc).
Upvotes: 1
Reputation: 58677
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.Upvotes: 5
Reputation: 13099
Have you tried git clone /path/to/myproject.git
?
Or git clone /path/to/my/copied/.git
Upvotes: 2