Tuesday, March 22, 2016

How to Change Git Commit

Change Git Commit Message

During one of my developer testing, I have changed my machine date with additional one month. After Testing the fix I committed the code. But then realised git use my machine date as committer date. Now when I check the git repo, my commit with date change show as the latest commit.

How to fix that.


Git Rebase

You can simply use git rebase for change commit message or date or remove that commit.

These are the steps I have used.

git rebase -i HEAD~10

set pick reword in the commit I want to change

git rebase -i HEAD~10

set pick to edit

git commit --amend --date "Wed Mar 9 15:42:22 2016 +0530"

git push

I had a  considerable amount of testing with my local repo. BETTER NOT TO CHANGE UR MACHINE DATE BEFORE COMMIT :)



No comments :

Post a Comment