Showing posts from August, 2021

Revert changes to a file in a commit || Revert changes to a file from pushed commit

Here are our git logs 343333 Good commit 457g222 In this commit we want some revert || BAD Commit 2343534 Initial commit Rebase from the previous commit of BAD Commit, amend the problem commit, & continue. 1) Start interactive rebase:    git rebase -i 2343534 2) Mark the problem commit for edit in the editor by changing pick to e (for edit):     e 457g222    pick 343333 3) Revert changes to the bad file:    git show -- file_that_you_want_to_revert.txt | git apply -R 4) Add the changes & amend the commit or make new commit    git add badfile.txt     git commit --amend / /if you want to amend it     git commit -m "your commit message here" / /if you want to create new commit 5) Finish the rebase or push to remote   git rebase --continue //if you did not created new commit in previous steps   git push origin_name branch_name -f   //if created new commit in previour steps