I tried
git commit --amend
git push --force origin mybranch
But I am not allowed to force-push to that branch because of administration. Any chance I can still change the remote commit message?
Nope. The commit message is part of the commit, so if you can't force push, there's no way to get a replacement commit in with a new message.
Amending your commit would change the SHA1 hash of your commit which would require the force push.
You could use a Git "note" perhaps...see https://git-scm.com/blog/2010/08/25/notes.html
From the link:
Wouldn't it be nice if you could add data to a commit without changing its SHA? If only there existed an external mechanism to attach data to a commit without modifying the commit message itself. Happy day! It turns out there exists just such a feature in newer versions of Git! As we can see from the Git 1.6.6 release notes where this new functionality was first introduced:
"git notes" command to annotate existing commits.
No. If you're not allowed to force push, you're not allowed to force push. git commit --amend
doesn't actually change any commit, it creates a new one, and although the previous commit is still around, it has been taken out of the history of the branch. The whole point of denying force push permissions is to prevent contributors from taking commits out of the history of the branch.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.