简体   繁体   中英

How can I push a specific branch of Git to my server?

I'm working to deploy a Django app. The app built on a Github OS project. I have this stored locally as the Master branch.

$ git branch   
* master  
  customized - customized with local dev settings  
  webfaction_customized - with production server settings 

The customizations for this project are stored in 2 separate branches.

My plan was to perform my customization locally in 'customized', then merge those changes into 'webfaction_customized'

Then push these changes to a bare repository on the production_server: I would then clone this bare repository on the production_server, change the settings in the cloned repository and restart the fcgi process.

The first problem was that I found this if I tried to push a branch to the server that wasn't master, I could not clone from the bare repository.

So I tried to push the master branch to the server.

git push webfaction_server master

But now I'm finding that none of my branches are uploaded.

Is there some way to push a specific branch to a bare repository and be able to clone that branch?

OR

Do I need to restructure my project so that Master branch is my customizations and the Github project would be in a github branch?

You would simply do:

git push origin webfaction_customized

Where origin is your remote name and webfaction_customized is your custom branch.

Hence, when you work on the master branch, you are pushing via:

git push origin master

你会简单地做:

git push origin localBranchName:remoteBranchName

The message Warning: Remote HEAD refers to nonexistent ref, unable to checkout. only tells you that the HEAD link does not exist and thus Git does not know which revision to check out to your local working directory.

Chances are that the branches on production_server themselves are created correctly. Just do a git checkout <whatever-branch-you-want> and start hacking away.

If it doesn't solve the issue, paste here the output of git branch -a and cat .git/config run n both repos.

Your push-command seems right, assuming webfaction_server is the name of a remote and not just the server address. Run git help remote to learn more about pushing and pulling to/from multiple remotes.

you may need to update the server information with git-update-server-info . This tool will update the HEAD information on the server with the recent commit hashes, updating old branches and making new branches visible. In particular, it will update the info/refs file in your git repository. You will need to run this on the server, so, perhaps something like the following could be useful:

ssh webserver "cd /path/to/your/repository.git/ && git-update-server-info"

It might be possible to trigger that update, possibly with a post-commit hook, but have not tried that yet.

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