Git workflow - shinmm/gohantimes-instapost GitHub Wiki
Git workflow
This workflow is something I've done in the past(and still use). This keeps the project more organized. I am learning new things everyday in an effort to become a better developer! I wrote this for a group project, since not everyone had experience with git/github. So while the language used here assumes a team of people working on the same project, this can also be used individually. Also, I think it is good practice for when you need to work on a team.(Which you definitely will have to do) I am not a veteran engineer yet, so if any modifications should be made, I'd appreciate the feedback!
The basic flow of events is listed below. Follow the Link for a more detailed explanation of each step.
- Create an Issue
- Create a local brach from master
- Work on implementation and make some commits
- Push local branch
- Create pull request
- Merge into master branch
1) Create an Issue
- At the top navbar below the repo name, click on issues
- Click on "new issue" to create the issue. The title should be meaningful, and should identify the feature being implemented or the bug being fixed. In the textarea below, write some more details on what you will do. Here I would write something like this
Tasks:
* Create "about page"
* Add styling for about page
* ...
Maybe a comment like "use this data file for tast a,b ..."
No need to make it super detailed, but it's also nice to link some resources you might find useful.
- On the right side under "asignees", select who will be working on the issue. In big teams this would be important, since we don't want multiple people to waste time working on the same issue. In our case, you might just assign the issue to yourself. !. Below, add a label, probably either enhancement or bug in our case
- Hit submit new issue
2) Create a local branch from master
- Make sure repo is cloned and run
git pull
to confirm you have the latest version of the master branch. (And also make sure you are on the master branch. If you want to see your current branch, rungit rev-parse --abbrev-ref HEAD
). Go to master branch withgit checkout master
- Create a local branch with
git checkout -b [ISSUE-TYPE]/#[ISSUE-NUM]_[describe_issue]
ISSUE-TYPE = feature(enhancement), fix(bug) (In out case)
ISSUE-NUM = shown on issue page
Example : If the issue number was #1, and the issue was to implement an about page, I might do something like:
git checkout -b feature/#1_about_page
If the issue number was #3, and the issue was to fix a bug that displayed the wrong image:
git checkout -b fix/#3_image_render
3) Work on implementation and make some commits
On the newly created local branch, work on your issue and make commits. Commit messages should somewhat indicate what changes you made with that commit. Let me know if I should write how to commit changes
4) Push local branch
Once you feel like you are done, and you commited your final changes, push the local branch with
git push origin HEAD
(You might only need git push depending on your configuration)
5) Create pull request
Once you push your local branch, go to the "pull requests" tab under the repo name. Your newly pushed branch should come up, with an option to create a new pull request. Click create new pull request. The title of the pull request can just be left as is in this case, it'll usually be the name of the branch. In the text area below, note something like :
Tasks completed:
* #xx (This is the issue number of the issue you were working on. This should show up as a hyperlink to issue)
List some changes you made not listed in issue, etc...
On the right hand side:
- Add everyone on the team as a reviewer
- Add the label, either enhancement or bug
- At this point, there will be an option below to merge into master. Don't do this until every reviewer has reviewed!!
6) Merge into master branch
Once everyone has approved the pull request, click "merge" to master and then delete the branch(Should give you the option to do it right after).
Once merged into master, be sure to checkout to master and do a git pull
to update your local repo.
And you're done!!
Common Scenarios that might need further action
// TODO: add scenarios
- Someone merges changes to master, while you are still working on your local branch.(Need to rebase )