

It is also possible to add more changes to the recent commit using amend. So it is always advisable to use amend when you haven’t pushed the changes to remote or if you are pretty confident that no other developers have started using those changes or no others have pushed any new changes to the current branch.Īdding more changes to the latest commit using amend So any changes that were pushed to remote meanwhile will be erased from the history and will be gone permanently. It is recommended not to use amend if you have already pushed the changes to remote and other developers have already started using those changes.īecause -force is basically rewriting the git history in remote itself. The above command will force the Git to push the local changes to remote. You can write script that will do it for you. So you should tell Git that the local changes are meant to be the updated changes and have to push it anyway. 1 Answer Sorted by: 0 You cant do it directly form within SourceTree. This is happening because we have used amend to change the latest commit and the remote is not aware of that. So you should probably fix it by pulling the changes from local. It means that there are new changes in the remote and those changes are not present in the local. If you do a reset -hard, you will need to force the push in order to complete your operation.

Git is rejecting to push and gives warning that the local branch is behind the remote. Git won’t allow you to push the changes and you will see the error message as below.

After realizing the mistake you have changed the commit message with amend and you are trying to push the changes to remote. Assume that you have committed some changes with wrong commit message and have pushed to the remote. And this command will directly commit the change and won’t open the editor to edit. You can pass the message directly with -m attribute. Git commit -amend -m "Your rewrite message"
