Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push changes to remote repo without commit

Tags:

git

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

like image 561
ryudice Avatar asked Jan 03 '11 06:01

ryudice


People also ask

Can I push changes without commit?

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

How do I push changes to my remote repository?

To push the commit from the local repo to your remote repositories, run git push -u remote-name branch-name where remote-name is the nickname the local repo uses for the remote repositories and branch-name is the name of the branch to push to the repository. You only have to use the -u option the first time you push.

Can I git push without pulling?

You can do a forced push. The forced push will erase all commit history of the remote repository's branch, and replace it to your branch. Check the answers for doing forced pushes in "How do I properly force a Git push?".


2 Answers

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

like image 197
Andrew Homeyer Avatar answered Sep 28 '22 05:09

Andrew Homeyer


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.

like image 23
fresskoma Avatar answered Sep 28 '22 04:09

fresskoma