We can propose changes and request for code review by creating a pull request. The general workflow is to create a branch, work on your changes, and open a pull request. Upon code review, the pull request can be merged on to the working branch. Pull requests encourages distributed development and the changes to the code repository transparent.
Pull requests helps everyone to contribute to the project no matter what the level of expertise of the team members. Let’s see how to open a pull request on GitHub.
Open a pull request
Choose the branch.
Click on New pull request link
The pull request page would show the additions in green, and subtractions in red color.
Add a commit to the code reviewer that describes the changes.
Click on the Create pull request button.
Alternatively, when we create a branch and push changes to GitHub, GitHub would automatically show the button to Compare & pull request.
Merge a pull request
If there are no merge conflicts GitHub would automatically detect and prompt to merge the pull request.
Click on the Merge pull request button to merge the pull request.
In the case of merge conflicts, we need to resolve the conflicts before the merge.
Merging using Git bash
[email protected] MINGW64 ~/SampleProject (git-branch-demo) $ git fetch origin [email protected] MINGW64 ~/SampleProject (git-branch-demo) $ git checkout -b git-branch-demo origin/git-branch-demo fatal: A branch named 'git-branch-demo' already exists. [email protected] MINGW64 ~/SampleProject (git-branch-demo) $ git merge master Already up to date. [email protected] MINGW64 ~/SampleProject (git-branch-demo) $ git checkout master Switched to branch 'master' Your branch is behind 'origin/master' by 3 commits, and can be fast-forwarded. (use "git pull" to update your local branch) [email protected] MINGW64 ~/SampleProject (master) $ git merge --no-ff git-branch-demo Merge made by the 'recursive' strategy. src/GitBranchFeatureDemo.java | 9 +++++++++ src/HelloWorld.java | 2 ++ 2 files changed, 11 insertions(+) create mode 100644 src/GitBranchFeatureDemo.java