How to undo/remove commits that removed functionality that is needed to be restored.

Let’s say you created a branch that removed some functionality/code and merged it back into master.

Then later on, down the road after any number of other branches/commits/merges, let’s say you want to add back that functionality/code from the past that was removed and also keep all the work done after that code was removed.

What is the best way to do this, and/or approach it if you think this scenario may happen? Basically how to remove code from a website, but also keep it for later use using git and GitHub.

Thanks!

If I did not understand it you could perform a reset to commit before the commit where this feature was deleted, then create a branch from it and then a pull request. Post the result branch here, because i’m curious to know if it will work.