Tried to deploy React app (with mistake), now need to revert to last successful commit #22256
-
Hi all, I tried to deploy a React app, which contained a wrong url, now my whole remote repo is transpiled and unreadable and I cannot revert to last successful commit on GitHub (the one BEFORE unsuccessful deployment). Any suggestions on this? Ideally I want to fix the url and deploy again (at some future point), but at least for now I’d need to revert to the last successful commit. Local repo is the most current correct version, remote version is the deployed wrong version (at the moment). Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Hi and welcome @free4moriginal , Let’s see if we can help you out. As I understand, the version that is currently on your remot (is it GitHub?) is wrong, while your local version is correct. You can override the remote version with your local version during pushing using the –force tag. An example: if the affected branch is master , you might want to git push --force origin master to force the remote to adhere to your local changes. Just make sure to properly read and understand the warning below before you force-push anything. If you have more questions, let us know. WARNING: IF YOU, FROM ANOTHER MACHINE, OR A CO-WORKER FOR EXAMPLE MADE CHANGES IN THE MEANTIME ON THE REMOTE YOU WILL DESTROY THEIR CHANGES |
Beta Was this translation helpful? Give feedback.
-
Thanks Mark! So I saw somewhere else this command: git push origin +master From your explanation I understand that it’s the same thing? So this will overwrite the remote repo completely (GitHub), or will it add a new commit to the HEAD which will be a reversion to the previous state? My understanding of git is somewhat basic still. |
Beta Was this translation helpful? Give feedback.
-
Yes, using +master is exactly the same as using —force. No, it will not create a commit to reverse the changes! It will just force push your local branch - so let’s say the last commit you have locally is commit A and on the remote you have commit A + the commit that messed things up, your local branch lacka behind. Normally you can’t push because you are behind, but when you force push you force the remote to comply with YOUR “idea” of how the Git history should be. That is exactly why this can be such a destructive action. If another person makes commits after you did, you normally can’t push and would be forced to first take their changes into account. By force-pushing you would discard their work. |
Beta Was this translation helpful? Give feedback.
-
So to answer, your question: “yes, it will override GitHub completely with what you have locally” (altough it is limited to the branch you specify, of course). |
Beta Was this translation helpful? Give feedback.
Hi and welcome @free4moriginal ,
Let’s see if we can help you out. As I understand, the version that is currently on your remot (is it GitHub?) is wrong, while your local version is correct. You can override the remote version with your local version during pushing using the –force tag.
An example: if the affected branch is master , you might want to git push --force origin master to force the remote to adhere to your local changes. Just make sure to properly read and understand the warning below before you force-push anything.
If you have more questions, let us know.
WARNING: IF YOU, FROM ANOTHER MACHINE, OR A CO-WORKER FOR EXAMPLE MADE CHANGES IN THE MEANTIME ON THE REMOTE YOU WILL D…