简体   繁体   中英

Git push to Staging Server

I'm trying to push only my Staging Branch to a bare repo on my staging server with the following command:

git push staging +staging:refs/heads/staging

But I get a fatal error:

you are on a branch yet to be born

If I replace staging with master on the command above it works and deploys my master branch/files to the staging server but my master branch is my production branch and I only want to deploy my staging branch/files.

Can anyone help?

Please bear in mind that I am a designer and not a developer, so a newbie styled answer would be appreciated ;o)

UPDATED

I thought I'd better explain my workflow... just in case it revels some answers to my issue/newbie situation:

  • I have my Origin @ Bitbucket - which holds my entire project
  • I cloned my repo to my local WAMP server for development (where I work on my develop branch)
  • I have three main branches: master (my production branchj / live server), develop (my local branch / WAMP server) and staging (my client acceptance branch / staging server)

I have no problem pushing the entire project to Bitbucket, but I'm struggling to push the files under the staging branch to my staging server.

NB: on my staging server git I'm using a post-receive hook: GIT_WORK_TREE=/path/to/site git checkout -f

I maybe trying to do this completely wrong, but I though I could deploy my code on the staging branch to my staging server?!

What you should do is:

  • push that branch
  • establish a tracking relationship between the local and the remote one

That is done in one command with:

git push -u staging staging

After that initial first push, and future push can be done with a simple:

git push

See more at " Why do I need to explicitly push a new branch? ".

Note that the "best practice" (or at least a better one) is to not name a remote repo reference ( staging ) and a branch ( staging ) with the same name, simply to make clearer in those git push command what ' staging ' is what.

RESOLVED

The issues I've faced have been resolved fully by updating my git post-receive hook:

FROM GIT_WORK_TREE=/path/to/site git checkout -f

TO GIT_WORK_TREE=/path/to/site git checkout -f staging

Who would have though it would have been such a simple thing ;o)

A big thanks to @VonC for all his help - somehow you led me off down the right path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM