Site icon TestingDocs.com

Create a pull request

Overview

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.

https://www.testingdocs.com/resolving-merge-conflicts-on-github/

 

Merging using Git bash

hp@LAPTOP-3NKORD70 MINGW64 ~/SampleProject (git-branch-demo)
$ git fetch origin

hp@LAPTOP-3NKORD70 MINGW64 ~/SampleProject (git-branch-demo)
$ git checkout -b git-branch-demo origin/git-branch-demo
fatal: A branch named 'git-branch-demo' already exists.

hp@LAPTOP-3NKORD70 MINGW64 ~/SampleProject (git-branch-demo)
$ git merge master
Already up to date.

hp@LAPTOP-3NKORD70 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)

hp@LAPTOP-3NKORD70 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

 

Git Tutorial on this website can be found at:

https://www.testingdocs.com/git-tutorials/

For more details on the Git, visit the official website at:

https://git-scm.com

Exit mobile version