I still have some difficulties to understand completely the process to modified an already pushed commit.
I am not working on the master branch (don't know if that matter), and I committed and pushed wrong data (say, clear password...) in the Commit_2 (see below).
I would like to change files from this commit only, and don't change the others.
Of course, I have read the documentation git-rebase, cherry-pick etc.. as well as some very nice answers from SO, like here or here, but I am still not sure how to do it.
So, basically, how can I change files from, and only from Commit_2 ?
commit 54sdf4f4d5f4dsf4555q5aaaa44fr Author: me <[email protected]> Date: Wed Sep 14 10:25:09 2016 +0200 Commit_3 commit ghgzf4x1522qx1x5f222y4d Author: me <[email protected]> Date: Tue Sep 13 15:01:42 2016 +0200 Commit_2 commit dfsdc4ycx45ds4fyc6d4fysfsd Author: me <[email protected]> Date: Tue Sep 13 14:57:08 2016 +0200 Commit_1
I like interactive rebase
git rebase -i ghgzf4x1522qx1x5f222y4d^
Set that commit from pick to e for edit. Then make your changes (delete password). Then continue.
git rebase --continue
Now that you have rewritten history, you will have to force push to the remote.
git push <remote> <branch> --force
And others will need to non-fast-forward pull.
git fetch <remote>
git reset --hard <remote>/<branch>
Or maybe
git pull --rebase
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With