Publishing bitbucket to digital ocean

痞子三分冷 提交于 2019-12-11 06:18:10

问题


I'm essentially trying to understand the concept of git using bitbucket; I've been practicing version control by modifying files between my local and bitbucket accounts which has proven helpful.

Now I'm trying to work out how you would push the files from a remote repo in bitbucket (or i guess GitHub or the like) to a cloud hosting solution such as digital ocean. Is that even recommended? I can't really google it because result come up as thinking I mean the bitbucket server, or want to host a site on bitbucket itself. I'm not sure if you would ask digital ocean to 'fetch' the files, or there is options within Bitbucket to push remotely and act intermediately.


回答1:


You can use post-receive hook in .git\hooks. The content of post-receive should be:

#!/bin/sh
git --work-tree=/droplet/repo --git-dir=/bitbucket/repo checkout -f

Now after you push changes to bitbucket, it will redeploy to droplet.

More detail, you can refer here.




回答2:


You need to add a new remote branch in your local repository.

This is how you will do it. git remote add (You will need a repository ready on the remote location)

Note that in the example above they add a remote repository called origin. You might want to change it to something else if you have cloned the repository from bitbucket.

After that whenever you do any operation regarding a remote repository you will have to mention which remote repository.

Ex for push

git push origin master
git push <remote_repo> <remote_branch>

I hope it helps.



来源:https://stackoverflow.com/questions/42055142/publishing-bitbucket-to-digital-ocean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!