I've got a staging server with Git on it, my buddy and I push changes to that Git repo from our local clones of that repo, when we're ready to make something public, we tag it 'n all that, but then I have to do a git reset --hard
to update the actual files on the server to HEAD, which seems a bit strange to me.
I think the issue might be a fundamental misunderstanding of how git works. Usually, I branch my code on my local repo, work on it, then merge it to the master repo, then git push
, is this correct?
It sounds like you're pushing to a non-bare repo on your server. When you push to a repo, the repo's internal state is changed, but the checked-out files are not updated, which is why you have to do a git reset --hard
(or a git checkout
) to checkout updated copies of the files. It is recommended to only push to a bare repo for this reason. You can create a bare repo using git --bare init
or git clone --bare
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With