Publishing bitbucket to digital ocean

2019-07-28 02:43发布

问题:

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.