My Environment:
I am working with team on github private repository.
We have only master branch.
Reproduce the problem:
-
I made change (i talking about single and not muilticase) and add+commit+push to github private repository.
-
I saw the message in github after my push – and i have mistake that i want to change.
-
How can I change the message of my push?
Edit:
Its important to me that no history will be left of my mistaken message.
Edit2:
The files already pushed they are in github repository and not only in my local repository
TL;DR
This will allow you to edit the last commit message, and replace the commit on the remote with your edits.
HOWEVER
You are most likely better off simply pushing a correction.
The only way to change an existing commit is:
That will allow you to easily edit your last commit (either contents, or commit message)
You’ll then find you can’t push to the remote, when you try it’ll be rejected with a warning like this:
Which gives you two options:
git push -f)If you pull first – you will put the un-edited commit back in your history, it’ll still exist, but you’ll have no problems pushing to your remote branch. The original commit will show up in the history as a merge.
If you force-push, you are literally forcing the remote branch to accept your local history and overwriting the remote branch’s history.
The note from git’s own help is perhaps best used to describe why forcing a push is generally a bad idea:
In context, the “lost commits” will be the old version of the commit you edited – but it could also include changes a colleague pushes in-between your first push, and the forced-push. For this reason it’s a risky manoeuvre.
If you need it it can be done – but either act quickly (so that nobody downloads the borked-commit) or know that you will cause problems for any other developer pulling and pushing to that branch.