Skip to content

Git Workflow

Sen Zhang edited this page May 28, 2017 · 1 revision

Git Workflow 'Forking + feature branch'

Workflow

  1. set up personal remote repo
    1. login to your own github account
    2. navigate to the shared public remote repo, distributed_message_queue
    3. click "fork" button on the right corner to get the exact copy of shared public repo
  2. set up personal local repo
    1. get a copy from personal remote repo which you just set
      $ git clone path/to/repo.git
      
    2. set a pointer, upstream, to shared public remote repo
      $ git remote add upstream https://github.com/jsongcat/distributed_message_queue.git
      
    3. verify your remote, when you clone a copy from your personal remote repo, git automatically create a pointer, origin, to your personal remote repo
      $ git remote -v
      origin https://github.com/<your own username>/distributed_message_queue.git (fetch)
      origin https://github.com/<your own username>/distributed_message_queue.git (push)
      upstream https://github.com/jsongcat/distributed_message_queue.git (fetch)
      upstream https://github.com/jsongcat/distributed_message_queue.git (push)
      
  3. create a feature branch at your personal local repo
    $ git branch myNewFeatureName
    $ git checkout myNewFeatureName
    
  4. write your code at your new feature branch at your personal local repo
    1. stage
      $ git add .
      
    2. commit
      $ git commit -m 'my commit summary'
      
  5. merge to shared remote repo (for code writer)
    1. update your personal local repo, aka, upstream
      $ git pull upstream master
      
    2. see the merge conflict
      $ git status
      
    3. save the merge result if there are conflicts
      $ git add .
      $ git commit -m 'my merge summary'
      
    4. merge your feature branch to your master branch at your local repo
      $ git checkout master
      $ git merge yourNewFeatureName
      
    5. solve the conflict if there are conflicts
    6. push updated local repo to your remote repo, aka, origin
      $ git push origin master
      
    7. file a pull request
      1. click the 'pull request' button on your remote repo page
      2. set shared public repo and branch, your public repo and branch
      3. assign the reviewer to review your code
      4. notify the reviewer automatically
  6. merge to shared remote repo (for code reviewer)
    1. review the code
    2. solve the conflicts
    3. approve the pull request by click 'rebase and merge' button

Reference

Atlassian git workflow tutorial

Clone this wiki locally