Git workflow (Dev>Staging>Live) basic technical questions

后端 未结 2 779
野趣味
野趣味 2021-02-03 11:56

I\'m quite new to Git (and VC for that matter) and I\'m struggling a bit to understand the concept behind the Dev>Staging>Live workflow using branches.

I\'m trying to ap

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-03 12:38

    You don't need to create different repositories. What you should learn and you'll probably love about git is how easy it is to work with branches. So step 1:

    • Forget about anything you know from your SVN background

    Now that we are all set, here is the idea. Let's say you have currently only master on your bitbucket:

    • Clone the repository:

      $ git clone git@bitbucket.org:user/example.com.git
      $ cd example.com
      
    • Create your branches:

      $ git branch dev
      $ git branch staging
      
    • Let others know about these branches:

      $ git push origin dev
      $ git push origin staging
      
    • Start working!

      $ git checkout dev
      $ touch new_file
      $ git add new_file
      $ git commit
      $ git merge master         # and resolve conflicts
      $ git checkout master
      $ git merge dev
      $ git push origin
      

    Note: The example above is a simple branch-experiment-merge, and would probably not reflect the exact workflow as your tutorial.

    So in short, you don't have different repositories, but branches in a single repository. Between these branches, you can merge as much as you want with whatever workflow you like. You can have additional branches that are not pushed to origin, so they are hidden from others. You should also of course git fetch/git merge the branches you want to work on every often to make sure you get the latest changes from other collaborators.

提交回复
热议问题