Victor Grazi Victor Grazi - 2 months ago 5x
Git Question

Is there a way to store my local commits on the remote without actually pushing a commit?

When I do a commit, it stores the commit locally but does not push it to the remote until I explicitly push it. That's good, it helps me keep me do small commits locally and then do a big push when the feature is complete

However I am concerned that in the event the machine crashes, all of the commits are lost.

So I am wondering if there is some way to store the local commits on the remote without actually pushing them. Kind of a reverse fetch


I don't know of any way of stashing local commits on the remote other than pushing, but why not just push a temporary branch? Assuming you are on branch feature, I would take the following steps:

git commit -m 'commit your work'
git checkout -b feature_backup
git push origin feature_backup

Now you have backed up the commit or commits in question. You can delete this branch when it is no longer necessary.