Hi, I’d like to hear out some suggestions about a Git problem I faced some days ago, how you would have handled it, and why that would’ve been better.
I was in a situation where a commit deleted some files in a remote repo, and other people worked on it and committed after.
<font color="#000000">$ git log -4 --graph --oneline</font> * 6e8a23b (HEAD -> master, origin/master) Added MergeSort algorithm in KotlinScript and Swift <font color="#FF0000">* 755bca9 purged all files excluded by .gitignore</font> * f2d6d7c (before-purge) Merge branch 'master' of https://github.com/... |\
The red commit deleted a lot files that needed to be restored, lots of them, spreaded all around the repository, so,
I wanted to restore all the deleted files while mantaining the successive commits’ changes.
A _ rebase --onto before-purge 755bca9 _ from master was what immediately came to mind, but that broke the repo’s history, so I had to do a reset --soft origin/master , an _ add -A _, and finally a commit.
So I basically used Git’s tools but at the end I had to “cheat” to be able to push something correctly, and I spent almost an hour trying different things to achieve what I wanted to do but I ended up having to resort on reset.
What could have been a better way to handle the issue? I tried searching the internet but I wasn’t able to find similar situations. Let me know!