Git Flow

Table Of Contents

Getting Started

This is our guide for contributing to SchoolStatus projects. These steps are based on this article.

Step 1: Setup a local copy on your computer

  1. Fork project

  2. Clone forked project to your local machine. Use ssh link. $ git clone [email protected]:mujuni88/sasha.git

  3. cd sasha

  4. Setup remote so that you can point to the original project to retrieve any new changes to your local copy.
    git remote add upstream [email protected]:schoolstatus/sasha.git

Step 2: Working on a feature

Fix the thing you are working on.

Todo

  1. Make sure you are on the correct branch git checkout branch
  2. Sync your local copy with upstream copy git pull. Then git push to sync to your forked copy.
  3. Create your new branch. Prefix branch with hotfix/ or feature/

General rule of thumb:

  • Working on a bug in production?

    create a branch from master

     $ git checkout master
     $ git pull upstream master && git push origin master
     $ git checkout -b hotfix/readme-update
    
  • Working on a new feature?

    create a branch from dev

     $ git checkout dev
     $ git pull upstream dev && git push origin dev
     $ git checkout -b feature/new-content
    

    Not sure how to write commit messages? Read Linell's post.

Step 3: Create a PR

  1. push your branch to the origin remote one $ git push -u origin hotfix/readme-update
  2. Click New pull request

Testing Pull Request

Instructions referenced from how to test-a-pull-request.

  1. Identify the PR number and branchname
  2. Ensure you are working on a clean directory by doing git status
  3. Get a copy of the PR git fetch upstream pull/347/head:feature/showmore
  4. When done checking out their work, use git checkout master to return to your local branch.

or you could create an alias

Copy/paste each line (one at a time) to gitbash or terminal window.

git config --global --add alias.pr '!f() { git fetch -fu ${2:-upstream} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f'

and

git config --global --add alias.pr-clean '!git checkout master ; git for-each-ref refs/heads/pr/* --format="%(refname)" | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done'

Once created the aliases are used as shown below.
To pull a pull request: git pr <id> to use the example above git pr 123

To delete all the pull requests created with git pr alias use: git pr-clean

results matching ""

    No results matching ""