-
Notifications
You must be signed in to change notification settings - Fork 3
Github workflow
Goal is to always keep the master branch functional. Every time you work on something, your work should be done in a separate branch. Once your new code is working, get the code approved, and merge the code into master.
You can experiment and break stuff in your branch, but don't break master.
Whenever you work on something, create a new branch.
In this demo, the branch is named 'add-home-page'
First you need to switch to the master branch, then download the latest files from github.
git checkout master
git pull origin master
Then you create a new branch.
git checkout -b add-home-page
The command git checkout -b
will create a new branch and switch to the new branch
Make changes, commit the changes. Try to make your commit message be descriptive so other people know what you did.
git add <path/to/file>
git commit -m 'your commit message'
If you don't want to type the name all the files, you can use git add .
to add all the changed files at once.
When you are done, push your branch to github.
git push -u origin add-home-page
The first time you push a new branch use git push -u origin <branch name>
.
The next time you push this branch, you can just use git push
.
We have Travis CI installed on this repo. Whenever you push something to the repo, Travis CI runs some tests to see if your changes broke something in the existing code base. The test can take a little while to run. If you code fails, fix the code, and push the fixes to github.
Once your code passes, then make a pull request.
Make a pull request so that someone else can look over your code.
Instructions for pull request We are using the 'Shared repository model'
In the comments of your pull request, add mention someone who you want to look at your code and leave message about what you did.
@wykhuh I added a new page. Please review
.
If a reviewer has some suggestions, make the changes on your local machine, commit, and push up the changes to github. Repeat the process of making changes and pushing the changes to github until a reviewer gives your code the thumbs up (:+1 :) 👍
After your code is approved, merge your branch to the master branch.
Switch to master branch, and pull the latest master branch from github
git checkout master
git pull origin master
Merge your branch into master.
git merge --no-ff add-home-page
If you have any merge conflicts, manually fix them. After you fix the files, commit the changes.
git add .
git commit
push master branch to github.
git push origin master
On the pull request page, you should either see 'Merge pull request' button or a message saying "We can’t automatically merge this pull request".
option 1) green 'Merge pull request' button
a. press that button to merge your changes to master
b. update your master branch
git checkout master
git pull master
option 2) a message saying "We can’t automatically merge this pull request"
a. update your master branch
git checkout master
git pull master
b. switch to your branch and merge master into your branch
git checkout add-home-page
git merge master
c. fix any conflicts and commit the changes
git add <files>
git commit -m 'commit message'
d. push revised branch to github
git push
e. you should see a green 'merge pull request' button. Follow the steps for option 1.
After you merge your branch into master, delete the new branch from github
On you pull request, you should see "Pull request successfully merged and closed" and "Delete branch" button.
Click "Delete branch"