I had a repo on which I had made several changes and accidentally lost my previous directories but luckily someone forked my repo before these changes happened and has all the files that I need so how do I fork my own repo from that someone? The fork repo option in github does nothing but take me to my own repo but without the changes. Please help me!!
If your friend's fork has the commit you want, you can create a sandbox with two remotes, fetch the commits from one, and push them to the other.
Assuming you already cloned yours, say
git clone my_url
then in that sandbox, add a second remote
git remote add friend friend_url
Fetch the commits from there
git fetch friend
Reset you local branch to where it's at on their fork
git checkout branch_name
git reset --hard friend/branch_name
And push that to your repo
git push origin branch_name
If Git complains that it's not a fast-forward push, then add --force
to the push command, after making sure you really don't want to keep the history you currently have for that branch on your own repo.
You can repeat this operation for any branch on their fork that you want to bring back in your own repo.
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.