Showing posts with the label commit

Revert pushed commit from git

There are 2 way to revert pushed code using git commands 1) First Way, Let suppose your current branch name is staging and you want to revert commit from staging git log   you will see commit details   now git checkout <commit_hash_where_you_want_to_point_your_head>                 in this picture i want to remove 1st commit                 so my command will be git checkout a804a3c4662334b0aa33860548841db54fb508bb         3. Now Head will be on second commit so create new branch from here git checkout -b staging_copy (name will be depends on you)      4. Now staging_copy branch does not have reverted commit, means its code is clean       5. Now delete your staging branch from local machine git branch -D staging    6. now rename your staging_copy branch to staging git branch -M staging    7. now we need to force push to staging branch git push origin staging -f This process is lengthy and complex but we are using this because in this proc