1

After working on a task for a couple of days, I realized that I referenced the wrong ticket number in my commits. Now they already pushed to the server, the server doesn't allow altering of commmits, but since it is not merged into master, I wondered if I still have a chance to change it. Maybe moving it all to a second branch and changing it there?

Stefan
  • 14,826
  • 17
  • 80
  • 143
  • Does this answer your question? [How to modify existing, unpushed commit messages?](https://stackoverflow.com/questions/179123/how-to-modify-existing-unpushed-commit-messages) – phd Apr 12 '20 at 15:26
  • https://stackoverflow.com/search?q=%5Bgit%5D+change+old+commit – phd Apr 12 '20 at 15:26

1 Answers1

1

You can use interactive rebase: git rebase -I HEAD~10. You will get the list of last 10 commits. You can set reword for each commit and change to commit message.

Then you need to push changes to remote branch using: git push --force-with-lease.

ceth
  • 44,198
  • 62
  • 180
  • 289