I pushed some shit I shouldn’t have

OK. So not the best mistake to make. But typically not so bad to recover from either.

The best bet in this scenario is to push a follow-up commit that is the inverse of your changes. git has a command for this:

git revert <commit hash>

Assuming you just pushed, and there have been no new commits since your push, your most recent commit will be the commit you want to revert, so this will suffice:

git revert HEAD

If you didn’t just push, use a tool like git log to view the commit history, and copy your commit hash once you find it. Then: git revert <your commit hash>

If your mistake isn’t the most recent commit, you should rerun all unit tests, and so on, before pushing your changes. This is because it’s possible that others have written code based off of what you did, so you make sure you consider the implications of undoing your changes. More often, though, you’ve realized you made a mistake shortly after making it, so git revert HEAD will do.

Once you’ve done that, there is now a commit with the inverse of your changes. i.e. if you added 3 lines, the new commit will have those three lines deleted. All you need to do now is push git push <remote> <branch name> example: git push origin develop