Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating a working tree to Git's HEAD

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?

like image 233
Zack Avatar asked Dec 23 '22 05:12

Zack


1 Answers

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.

like image 130
mipadi Avatar answered Jan 28 '23 08:01

mipadi