If you've copied a project repository, cloned it down to your local system, and added a Git remote to your clone that point to the original repository on GitHub, now you're ready to make some changes in code. Far as you will be making changes to your local Git repository and collaborate with others on the same repo, you should use a branch. Good way to manage your branches is using a SourceTree.
The flow looks like this:
- Create and checkout a new branch.
- Make changes.
- Commit your changes to the branch.
- Push the changes to GitHub.
To create a new branch and check it out (telling Git you will be making changes to the branch), use this command:
To push the new branch on GitHub:
As far as you make changes in the files, you will need to commit those changes using the command:
Adds the files in the local repository and stages them for commit.
Commit the files that you have staged in your local repository:
Push the changes you made in that branch back to GitHub would look like this:
In this case, you are pushing the changes in the name_of_your_new_branch branch to origin remote.
In case you want to push code to existing repository, in the last line you need to specify the repository, for example changing the master
branch:
If you're created a pull request from a branch within a repository. To create a pull request, you must have changes committed to your new branch.
Go to the repository page on GitHub and click on "Pull Request" in the repo header:
Use the base branch drop-down menu to select the branch you'd like to merge your changes into:
Enter a title and description of the pull request.
Effective Pull Request looks like:
- Make it small and clean piece of code.
- Make sure all tests pass - ESLINT and tests before final commit.
- Checked and compare with ticket requirements before releasing to others.
- In description add link to Jira ticket, notes and if any screenshot (for that you can use Gyazo).
Pull request are necessary to fostering code review.
Review process looks like:
- Create Pull Request.
- Check Pull Request.
- Share on slack and move into "Review" column in Jira.
- Minimum two persons will review the Pull Request.
- After review a ticket can be move in Jira.
- The successful proposed changes, can be merge to the head branch of the base branch that was specified in the pull request.