GitHub is a version management and collaboration tool for programming. It allows you and others to collaborate on projects from any location.
Developer Workflow
A standardized workflow which dictates how changes/updates can be done for an application will help developers follow the required development practices to ship secure and robust code. Traditionally a development workflow will include defining requirements, development, testing, release, and production stages.
When a developer receives any work items or a requirement they will start working on it to provide the changes.
A requirement can be defined in GitHub by creating an issue. Issues to keep track of ideas, enhancement tasks, and bugs for projects that are linked to our GitHub Repository. So, between the developer and the project manager, we have a comprehensive process as well as an end-to-end solution in your Repository.
- Click the New Issue button
- Give your issue the title ‘Setup GitHub pages’
- Give a clear description e.g., ‘Need to setup GitHub Pages in this repository’
- Assign the issues to a Developer
- Click Submit new issue
Our project is by default on the main branch. This branch will usually be protected to not allow any breaking changes (which can be problematic if you haven't thoroughly examined your modifications!). The developer will create a new branch to submit any new changes or resolve any bugs.
- Open your Repository and click the Code tab
- Click Branch: main in the drop-down
- In the field, enter a name for your branch (e.g., ‘Feature’)
- Click Create branch
First, checkout to your new branch. Then, add all the files you want to commit to staging. Lastly, commit all the files you just added.
Now we can safely work within our branch, let’s create a file and make our first commit.
- Make an edit (just add a simple comment to your code) to one of the files you had added to the Repository earlier
- Give the commit a name and description
- Make sure your newly created (Feature) branch is selected
- Click Commit changes
It's time to open a pull request after you're sure that the modifications are complete. Your group will discuss from here. The branch will be merged into the main branch once the changes have been accepted. Let's have a look at an example
Each work item can be planned as an Issue, with tags, assignees, etc. When the developer commit code relevant to that Issue, referencing it in the commit message by the Issue number (eg #123) will hyperlink that commit on the Issue page. This hyperlink will do it for traceability. You can also close the issue from the commit with comments like Fix #123 or Closes #123.Traceability allows you to track work items across the development lifecycle to where requirements are implemented in the code.
A pull request is something shows us changes that we have pushed to newly created branch (e.g., ‘Feature’) in a Repository on GitHub.
- Open the Pull requests tab and click New pull request
- In the base: drop-down menu, ensure the main branch is selected
- In the compare: drop-down menu, select the Feature branch you created earlier
- Click Create pull request
- Now enter a title & description for your pull request
- Click Create pull request!
After you create a pull request, you can ask a specific person/team to review the changes you've proposed. If you're an organization member, you can also request a specific team to review your changes. Enforce this policy we use branch protection rule . To protect your main branch against unapproved/breaking changes, we can enforce a set of policies So how will you enable those policies by enabling branch protection rule. So, using branch protection rule you enable some feature like reviewer must approve this changes & you can enable status check.
- Require a pull request before merging
When enabled, all commits must be made to a non-protected branch and submitted via a pull request before they can be merged into a branch that matches this rule.
- Require status checks to pass before merging
Status checks let you know if your commits meet the conditions set for the repository you're contributing to.
- Merge a pull request into the upstream branch when work is completed. Anyone with push access to the repository can complete the merge. Once your branch has been merged, if you don’t need it anymore. You can click Delete branch!
Conclusion
You’ve learned how requirements defined in GitHub using issues. Developer will establish a new branch and submit those changes to work on that specific requirement. We also learned how to maintain traceability by attaching a commit to an issue, and then how to merge those changes into the main branch.