简体   繁体   中英

Git production and development server workflow

I am not sure whether the git workflow I intend to create between my production and development server is the right way of doing it.

This is what i have in mind: Development takes place on local computers and commits are git push to development server. Once a stable release is available, the production server does a git pull from development server. Any unexpected results on production can be reverted with git revert

Is it the correct way of doing this? If so, how do I make existing code sitting on the development server, a remote repo? Presumably, it's remote to both production and local as they pull and push .

在此处输入图片说明

Is it the correct way of doing this?

Yes, that sounds completely reasonable.

If so, how do I make existing code sitting on the development server, a remote repo? Presumably, it's remote to both production and local as they pull and push.

Say you normally access your repo through ssh, like this:

brian@local$ ssh brian@development
brian@development$ cd /home/brian/code
brian@development$ git status

Then you can clone this code with git clone ssh://brian@development:/home/brian/code . You should be able to git push and git pull to and from development from then on.

Is it the correct way of doing this? If so, how do I make existing code sitting on the development server, a remote repo? Presumably, it's remote to both production and local as they pull and push .

Git is just a tool, there isn't any corrent way or how you use it makes it the correct way .

For your situation:

  • There are 3 server ( or says 3 git repo )
  • Local --push-to--> Development
  • Production <--pull-from-- Development

So you can build Development git repo first, then clone to Production and Local:

user@development $ setup_git_repo.sh
user@local $ git clone ssh://user@development:/path/to/git/repo
user@production $ git clone ssh://user@development:/path/to/git/repo

Or you may clone via http:

user@development $ setup_git_repo.sh
user@local $ git clone http://development.server/git/repo
user@production $ git clone http://production.server/git/repo

Then you have 3 git repo. Local git repo and production git repo are cloned from development git repo.

Finally, you may do daily coding in local and push to development. Do some test on development and release with new tag. Run git pull on production server to get the latest code.

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