user3449833
user3449833

Reputation: 809

Bitbucket git process ensure master only

Pretty new to git, I wanted to check if my process is reasonable, and ensure that my deployed production web server only ever sees the master repo.

I have an "origin" repo on bitbucket. I've cloned it to my development server where I'm doing most of my work. To get changes into production it goes like this:

On development server:

make changes    
git commit -am 'message'
git push    # to bitbucket

On production server:

git pull    # from bitbucket

On the production server I've got a post-merge hook that does a checkout to send it to the /www directory, and also change a couple of settings (turn off debug, etc).

Is this a normal way to do this? If I work on extra features in separate branches on my development server and push those to bitbucket, do I need to worry about my production server "accidentally" picking those up on a git pull and/or checking them out? Does git pull only do "master" unless otherwise told? Ideally I'd like the production server to only ever see "master", but I want other branches on bitbucket so other people can see the code I'm working on.

Upvotes: 2

Views: 73

Answers (1)

Jonathan.Brink
Jonathan.Brink

Reputation: 25383

git pull is a two-step operation:

  1. fetch - this will download all the content from the Git server defined by the "origin" remote (master branch and otherwise, but the actual checked-out code is not altered).
  2. Update branch pointer - Git will attempt to determine what the tracking branch is for the branch that HEAD is pointing to

There's a lot to grasp in those two steps, but I think I can make this easy.

On your production server, run these two commands whenever you want to update:

git checkout master
git pull origin master

This way only the changes pushed to your master branch will be deployed.

Upvotes: 2

Related Questions