I have self-taught working with git repositories wanted to create the following environment which fits my needs.
- I code on my local machine
- I have a bitbucket repository, where I keep everything update (as far as I understand, my origin)
- I want to push code to a production server over ssh
Everything is working as expected, I only have one problem while pushing to the production server. I always need to login to the server by shell to make a hard reset before the latest pushed commit is visible on the frontend. It looks like the last push is simply not getting "activated" on the production side.
I have the following workflow to setup my environment:
- I create a git repo on my production server with git init
- I clone the repo on my local machine with git clone ssh://urlToRepo
- I create a new repo on bitbucket
- On my local machine, I link the bitbucket repo with git remote add origin URL
- I work on my code, commit and push it to both remotes.
- On bitbucket, the commit is visible as expected.
- On the production server, the changes are not active. I need to do a git reset --hard to have them visible.
To get my pushes accepted on the production side, I also need to configure git config receive.denyCurrentBranch ignore. I tried git init --bare thinking maybe with a bare repo, I do not have this problem. Unfortunately, no files are shown at all on the server.
As you see, I'm probably not fully understanding the concept. Does anybody know how to help and hint me into the right direction?
Thanks already.