简体   繁体   中英

deleted directory in Git by mistake

By mistake I have deleted a directory in my git repo, and commited it.

I have done

git checkout LONG_SHA_ID

where LONG_SHA_ID is the ID of the previous commit, and I have got the directory back, but also I have got back the previous versions of some files that I have fixed in the latest commit.

How can I get back the deleted directory, with the latest version of the other files?

做这个:

git checkout LONG_SHA_ID -- /path/of/directory/you/deleted

Checkout the branch with the fixed files, and do git reset --mixed HEAD^ . This will undo the commit so you can try again without deleting the folder.

Just revert back the last commit by

git revert HEAD

That will back out the most recent commit. Then just push it up. You can replace HEAD with the revision you want out.

For more details about undo a git commit, look on here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM