3 ms·
The problem occurs when you amend a commit that someone else is already using. That is rewriting the shared history. A merge commit is required to get the branc
by eosrei 10y ago
The problem occurs when you amend a commit that someone else is already using. That is rewriting the shared history. A merge commit is required to get the branches in sync again.
Amending your commit in your own feature branch or fork isn't a problem. I often amend commits to make a cleaner git history to ease PR/code review.
git checkout master
git checkout -b 10-new-feature
# Make changes
git add example.code
git commit
git push origin 10-new-feature
# Oops... left a debug message, fix it.
git add example.code
git commit --amend
git push -f # Rewrites the remote history with your local modified version
Consider --amend as the "Just the last commit" form of rebasing.