简体   繁体   中英

Git : Delete a branch and go back to the previous status

I was working in branch "tree" containing three files xc, yc and zc (all are committed). I created a new branch "stack" (inside "tree"), added two files wc, zc Then I remembered "stack" should have been created from "DataStructure". So I switched back to "tree" and deleted the branch "stack" (git -d branch stack).

But in "tree" xc, yc zc && wc, zc are present. How will I get the previous status of tree branch (only xc, yc zc files).

I tried: git reset --hard sha_of_last_commit_in_tree , didn't work.

After you did git reset --hard last_commit_in_tree what's git status of your files in repo? Are they all in index? Where do you see them? I agree with @Saifu Khan it seems you forgot to switch to stack branch. Look at "git log tree" to understand what happend in this branch.

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