I wrote the wrong thing in a commit message. Alternatively, I ve forgotten to include some files.
How can I change the commit message/files? The commit has not been pushed yet.
Sommaire |
I wrote the wrong thing in a commit message. Alternatively, I ve forgotten to include some files.
How can I change the commit message/files? The commit has not been pushed yet.
git commit --amend
Will open your editor, allowing you to change the commit message of the most recent commit. Additionally, you can set the commit message directly in the command line with:
git commit --amend -m "New commit message"
…however, this can make multi-line commit messages or small corrections more cumbersome to enter.
Make sure you don t have any working copy changes staged before doing this or they will get committed too. ( Unstaged changes will not get committed.)
http://stackoverflow.com/questions/41003071/why-must-i-force-push-after-changing-a-commit-message http://stackoverflow.com/questions/41003071/why-must-i-force-push-after-changing-a-commit-message
git push <remote> <branch> --force # Or git push <remote> <branch> -f
Warning: force-pushing will overwrite the remote branch with the state of your local one . If there are commits on the remote branch that you don t have in your local branch, you will lose those commits.
http://en.wikipedia.org/wiki/SHA-1 http://en.wikipedia.org/wiki/SHA-1
Another option is to use interactive rebase.
This allow you to edit any message you want to update even if its not the latest message
In order to do a git squash follow those steps:
// X is the number of commits to the last commit you want to be able to edit git rebase -i HEAD~X
Once you squash your commits - choose the e/r for editing the message
https://i.stack.imgur.com/LVcm9.png https://i.stack.imgur.com/LVcm9.png
License : cc by-sa 3.0
http://stackoverflow.com/questions/179123/how-to-modify-existing-unpushed-commits