'Push changes to remote repo without commit

Is it possible to push changes to a remote repository without commiting to the master branch? I use the remote repo just for deploying.

git


Solution 1:[1]

No, there is no way to do that, as it would completely oppose the whole "git strategy", I guess. I don't know about your deployment system, but I guess a good way to do what you are trying to is to work on different branches (that is, on for development and one which gets deployed when pushed to), and merging the changes you want to be deployed from your development-branch into your live branch.

Solution 2:[2]

You can create an empty commit and push that: git commit --allow-empty

Solution 3:[3]

No, you must make a commit before you can push. What is being pushed is the commit (or commits).

Solution 4:[4]

If you want to push a specific commit:

git push <remotename> <commit SHA>:<remotebranchname>

Solution 5:[5]

You can amend your last commit with the --no-edit option then force push the branch.

git commit --amend --no-edit
git push origin <remote name> -f

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jacob
Solution 2 Andrew Homeyer
Solution 3 Ryan Bigg
Solution 4 sabalaba
Solution 5 cbaigorri