{"id":109666,"date":"2020-04-16T12:59:03","date_gmt":"2020-04-16T12:59:03","guid":{"rendered":"https:\/\/www.softwaretestinghelp.com\/?page_id=109666"},"modified":"2025-04-01T08:14:47","modified_gmt":"2025-04-01T08:14:47","slug":"advanced-git-commands","status":"publish","type":"page","link":"https:\/\/www.softwaretestinghelp.com\/advanced-git-commands\/","title":{"rendered":"Advanced Git Commands And GitHub Integration Tutorial"},"content":{"rendered":"\n<p><strong>This Tutorial Explores Useful Git Commands such as Git Stash, Git Reset, Git Cherry Pick, Git Bisect &amp; Explains how to Integrate GitHub with Jira:<\/strong><\/p>\n\n\n\n<p>In our previous tutorials in this series, we have seen most of the features of GitHub.<\/p>\n\n\n\n<p><strong>In this tutorial, we will look at the following:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Creating Releases<\/li>\n\n\n\n<li>Integration with Atlassian Jira<\/li>\n\n\n\n<li>Most commonly used Git commands for Developers\n<ul class=\"wp-block-list\">\n<li>Git Stash<\/li>\n\n\n\n<li>Git Cherry Pick<\/li>\n\n\n\n<li>Git Reset<\/li>\n\n\n\n<li>Git Bisect<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>=> <a href=\"https:\/\/www.softwaretestinghelp.com\/github-tutorial\/\">Take A Look At The GitHub Guide Here.<\/a><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><em><wp-block data-block=\"core\/more\"><\/wp-block><\/em>Creating Releases<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Advanced-Git-Commands.png\"><img decoding=\"async\" width=\"650\" height=\"366\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Advanced-Git-Commands.png\" alt=\"Advanced Git Commands\" class=\"wp-image-110117\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Advanced-Git-Commands.png 650w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Advanced-Git-Commands-300x169.png 300w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><\/figure>\n\n\n\n<p>Releases in GitHub is used to bundle your software, add release notes and binaries (WAR, EAR, JAR files) for customers and people to use the same.<\/p>\n\n\n\n<p>To create a Release, go to the main page of the repository and click on the <strong>Releases<\/strong> tab under <strong>Manage topics.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Manage-topics.png\"><img decoding=\"async\" width=\"740\" height=\"220\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Manage-topics.png\" alt=\"Releases Tab\" class=\"wp-image-109681\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Manage-topics.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Manage-topics-300x89.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p>Click on <strong>Create a New Release.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Click-on-Create-a-new-release.png\"><img decoding=\"async\" width=\"740\" height=\"631\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Click-on-Create-a-new-release.png\" alt=\"Create a new release\" class=\"wp-image-109682\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Click-on-Create-a-new-release.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Click-on-Create-a-new-release-300x256.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p>Provide a Tag and a Release title. The binaries are also added to the release. Once done click on<strong> Publish Release.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Publish-Release.png\"><img decoding=\"async\" width=\"740\" height=\"440\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Publish-Release.png\" alt=\"Release Published\" class=\"wp-image-109683\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Publish-Release.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Publish-Release-300x178.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p>The release is now ready with the source code and binaries.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">GitHub Integration With Jira<\/h3>\n\n\n\n<p>One of the important traceability aspects is to reference the Jira issue with the commits in GitHub. GitHub can be integrated with Jira not only just to reference the issue but also to help create branches and Pull Request from within Jira.<\/p>\n\n\n\n<p>So typically, once the developer starts to work on the task or bugs, a branch is created by him. Post the development or resolving the bugs a pull request can be created from Jira to merge to the main <strong>master <\/strong>branch. The branch created by the developer can then be deleted.<\/p>\n\n\n\n<p>To set up the integration, we have used a plugin <strong>Git Integration for Jira.<\/strong> This is a commercial plugin. The plugin can be downloaded from <a href=\"https:\/\/marketplace.atlassian.com\/apps\/4984\/git-integration-for-jira?hosting=cloud&amp;tab=overview\" target=\"_blank\" rel=\"noopener nofollow\">here<\/a><\/p>\n\n\n\n<p>Install the plugin in Jira from <strong>Admin -&gt; Add-ons.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Admin-Add-ons.png\"><img decoding=\"async\" width=\"196\" height=\"259\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Admin-Add-ons.png\" alt=\"Install Plug in\" class=\"wp-image-109684\"\/><\/a><\/figure>\n\n\n\n<p>Once the plugin is installed go to <strong>Application -&gt; Git Repositories<\/strong> and connect to GitHub.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Application-Git-Repositories.png\"><img decoding=\"async\" width=\"740\" height=\"285\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Application-Git-Repositories.png\" alt=\"Connect to Git Repositories\" class=\"wp-image-109685\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Application-Git-Repositories.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Application-Git-Repositories-300x116.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p>Enter the GitHub username and password. Click <strong>Connect<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Click-Connect.png\"><img decoding=\"async\" width=\"700\" height=\"397\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Click-Connect.png\" alt=\"Enter GitHub Username and Password\" class=\"wp-image-109686\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Click-Connect.png 700w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Click-Connect-300x170.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/a><\/figure>\n\n\n\n<p>The repositories mentioned for the user account will be displayed. Click on <strong>Import Repositories <\/strong>to finish the integration setup.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Click-on-Import-repositories.png\"><img decoding=\"async\" width=\"740\" height=\"286\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Click-on-Import-repositories.png\" alt=\"Import repositories\" class=\"wp-image-109688\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Click-on-Import-repositories.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Click-on-Import-repositories-300x116.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><span style=\"color: #ff6600;\">GitHub Commit With Jira Issue<\/span><\/h4>\n\n\n\n<p>As a part of the commit message enter as shown below. Click on <strong>Commit Changes<\/strong>.<\/p>\n\n\n\n<p><span style=\"text-decoration: underline;\"><strong>Example 1:<\/strong><\/span> Below is an example of <strong>Smart Commit<\/strong> which allows the developers to perform actions on the Jira issues from the commit message. One such command is the <strong>#comment<\/strong> along with the Issue key that adds the comment to the Jira issue as shown below.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Click-on-Commit-changes.png\"><img decoding=\"async\" width=\"692\" height=\"307\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Click-on-Commit-changes.png\" alt=\"Click on Commit changes\" class=\"wp-image-109689\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Click-on-Commit-changes.png 692w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Click-on-Commit-changes-300x133.png 300w\" sizes=\"(max-width: 692px) 100vw, 692px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Commits.png\"><img decoding=\"async\" width=\"740\" height=\"229\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Commits.png\" alt=\"Git Commits\" class=\"wp-image-109690\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Commits.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Commits-300x93.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p>Comments section updated.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Comments-section-updated.png\"><img decoding=\"async\" width=\"504\" height=\"131\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Comments-section-updated.png\" alt=\"Comments section updated\" class=\"wp-image-109691\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Comments-section-updated.png 504w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Comments-section-updated-300x78.png 300w\" sizes=\"(max-width: 504px) 100vw, 504px\" \/><\/a><\/figure>\n\n\n\n<p><span style=\"text-decoration: underline;\"><strong>Example 2:<\/strong><\/span> Assign to a user and update time spent as 4 h.<\/p>\n\n\n\n<p>Use the <strong>#assign <\/strong>and<strong> #time<\/strong> smart commit command in the commit message.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Assign-to-a-user-and-update-time-spent.png\"><img decoding=\"async\" width=\"682\" height=\"312\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Assign-to-a-user-and-update-time-spent.png\" alt=\"Assign to a user and update time spent\" class=\"wp-image-109692\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Assign-to-a-user-and-update-time-spent.png 682w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Assign-to-a-user-and-update-time-spent-300x137.png 300w\" sizes=\"(max-width: 682px) 100vw, 682px\" \/><\/a><\/figure>\n\n\n\n<p>Both the actions have been completed.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Both-the-actions-completed.png\"><img decoding=\"async\" width=\"740\" height=\"335\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Both-the-actions-completed.png\" alt=\"Actions completed\" class=\"wp-image-109693\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Both-the-actions-completed.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Both-the-actions-completed-300x136.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p><span style=\"text-decoration: underline;\"><strong>Example 3:<\/strong><\/span> Change the status of the issue to <strong>In Progress<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Both-the-actions-have-been-completed.png\"><img decoding=\"async\" width=\"683\" height=\"301\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Both-the-actions-have-been-completed.png\" alt=\"Status Change to In Progress\" class=\"wp-image-109695\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Both-the-actions-have-been-completed.png 683w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Both-the-actions-have-been-completed-300x132.png 300w\" sizes=\"(max-width: 683px) 100vw, 683px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Implement-Reset-Feature.png\"><img decoding=\"async\" width=\"740\" height=\"566\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Implement-Reset-Feature.png\" alt=\"Implement Reset Feature\" class=\"wp-image-109696\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Implement-Reset-Feature.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Implement-Reset-Feature-300x229.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><span style=\"color: #ff6600;\">Create A Branch <\/span><\/h4>\n\n\n\n<p>As tasks and bugs are assigned to developers, they need to start working on the development. For this they create a branch for the issue they are working on, do the development activities and raise a pull request to merge into the master branch.<\/p>\n\n\n\n<p>In the Jira issue at the bottom click on <strong>Create Branch.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Create-Branch.png\"><img decoding=\"async\" width=\"105\" height=\"44\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Create-Branch.png\" alt=\"Create Branch\" class=\"wp-image-109697\"\/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Create-Branch-Page.png\"><img decoding=\"async\" width=\"513\" height=\"268\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Create-Branch-Page.png\" alt=\"Create Branch Page\" class=\"wp-image-109698\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Create-Branch-Page.png 513w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Create-Branch-Page-300x157.png 300w\" sizes=\"(max-width: 513px) 100vw, 513px\" \/><\/a><\/figure>\n\n\n\n<p>Click on <strong>Create branch.<\/strong><\/p>\n\n\n\n<p>In GitHub, make a change to the file in the above-created branch and commit the same.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Make-change-to-file-in-created-branch.png\"><img decoding=\"async\" width=\"679\" height=\"313\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Make-change-to-file-in-created-branch.png\" alt=\"Make change to file in created branch\" class=\"wp-image-109700\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Make-change-to-file-in-created-branch.png 679w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Make-change-to-file-in-created-branch-300x138.png 300w\" sizes=\"(max-width: 679px) 100vw, 679px\" \/><\/a><\/figure>\n\n\n\n<p>As the development is completed the user can then raise a Pull Request from Jira.<\/p>\n\n\n\n<p>At the bottom of the issue click on <strong>Create Pull Request.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Create-pull-request.png\"><img decoding=\"async\" width=\"149\" height=\"44\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Create-pull-request.png\" alt=\"Pull request\" class=\"wp-image-109701\"\/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Create-pull-request-page.png\"><img decoding=\"async\" width=\"512\" height=\"266\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Create-pull-request-page.png\" alt=\"Create pull request page\" class=\"wp-image-109703\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Create-pull-request-page.png 512w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Create-pull-request-page-300x156.png 300w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/a><\/figure>\n\n\n\n<p>Click on <strong>Create. The Pull Request will be shown as Open.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Pull-request-is-show-as-Open.png\"><img decoding=\"async\" width=\"255\" height=\"29\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Pull-request-is-show-as-Open.png\" alt=\"Pull request is show as Open\" class=\"wp-image-109704\"\/><\/a><\/figure>\n\n\n\n<p>The next step is to merge the pull request in GitHub.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Merge-the-pull-request-in-GitHub.png\"><img decoding=\"async\" width=\"674\" height=\"709\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Merge-the-pull-request-in-GitHub.png\" alt=\"Merge the pull request in GitHub\" class=\"wp-image-109705\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Merge-the-pull-request-in-GitHub.png 674w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Merge-the-pull-request-in-GitHub-285x300.png 285w\" sizes=\"(max-width: 674px) 100vw, 674px\" \/><\/a><\/figure>\n\n\n\n<p>The status is updated accordingly in Jira.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Status-is-updated-accordingly-in-Jira.png\"><img decoding=\"async\" width=\"284\" height=\"30\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Status-is-updated-accordingly-in-Jira.png\" alt=\"Status is updated accordingly in Jira\" class=\"wp-image-109706\"\/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Advanced Git Commands For Developers<\/h3>\n\n\n\n<p>In this last section, we will look at some of the commonly used Git commands for developers. Nothing to do with GitHub but will aid the developers before they push the changes to GitHub.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span style=\"color: #ff6600;\">Git Stash<\/span><\/h4>\n\n\n\n<p>In most of the project scenarios when you are working on a new feature or enhancement, suddenly there would be a need for you to work on an urgent defect that has been reported and is a show stopper. As you are midway into your new work and not completed it there is no point in committing the changes which are half done.<\/p>\n\n\n\n<p>So, it is better to suspend or save the half-done work temporarily, work on the bug and come back to work on the new feature or enhancement. Git stash provides a solution to this. You can easily switch the context of doing changes quickly.<\/p>\n\n\n\n<p><span style=\"text-decoration: underline;\"><strong>Example 1<\/strong>:<\/span> Assume that you are working on a task assigned to you and when you look at the status, it shows that it is untracked as of now.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Stash-example1.png\"><img decoding=\"async\" width=\"740\" height=\"186\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Stash-example1.png\" alt=\"Example of Git Stash\" class=\"wp-image-109707\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Stash-example1.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Stash-example1-300x75.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p>Suddenly there is a high priority bug assigned to you. Thus, we need to temporarily save or stash the work currently being worked on.<\/p>\n\n\n\n<p>Run the following command.<\/p>\n\n\n\n<p><strong>git stash save \u201cMessage\u201d<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Temporarily-Save-or-Stash-the-work.png\"><img decoding=\"async\" width=\"740\" height=\"284\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Temporarily-Save-or-Stash-the-work.png\" alt=\"Temporarily Save or Stash the work\" class=\"wp-image-109722\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Temporarily-Save-or-Stash-the-work.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Temporarily-Save-or-Stash-the-work-300x115.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p>At this moment the working directory is clean. Any new commits can be made and if there are bugs then you may switch branch to work on it etc.<\/p>\n\n\n\n<p>When you want to re-apply the changes where you had left, use the command.<\/p>\n\n\n\n<p><strong>git stash pop<\/strong><\/p>\n\n\n\n<p>The above command will remove the stash from the list and will apply the last saved state.<\/p>\n\n\n\n<p>You can also use:<\/p>\n\n\n\n<p><strong>git stash apply<\/strong><\/p>\n\n\n\n<p>The above command will keep the changes in the stash and not remove them.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Stash-Apply.png\"><img decoding=\"async\" width=\"740\" height=\"490\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Stash-Apply.png\" alt=\"Git Stash Apply\" class=\"wp-image-109723\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Stash-Apply.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Stash-Apply-300x199.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p>Now the changes are reapplied and you can commit the changes.<\/p>\n\n\n\n<p><span style=\"text-decoration: underline;\"><strong>Example 2:<\/strong><\/span> Stash your changes, switch branch and merge changes.<\/p>\n\n\n\n<p>Make the change to the Html file in the <strong>master<\/strong> branch and stash changes.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Example-2-Stash-your-changes.png\"><img decoding=\"async\" width=\"740\" height=\"535\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Example-2-Stash-your-changes.png\" alt=\"Example 2 Stash your changes\" class=\"wp-image-109724\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Example-2-Stash-your-changes.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Example-2-Stash-your-changes-300x217.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p>Next is to switch to the <strong>bug<\/strong> branch, make changes and commit changes.<\/p>\n\n\n\n<p><strong>git checkout -b bug<\/strong><\/p>\n\n\n\n<p>Make changes to the Html file.<\/p>\n\n\n\n<p><strong>git commit -a -m \u201cFixed email issue\u201d<\/strong><\/p>\n\n\n\n<p>Switch back to the <strong>master<\/strong> branch and reapply changes from stash.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Switch-back-to-master-branch.png\"><img decoding=\"async\" width=\"740\" height=\"383\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Switch-back-to-master-branch.png\" alt=\"Switch back to master branch\" class=\"wp-image-109725\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Switch-back-to-master-branch.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Switch-back-to-master-branch-300x155.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p>Now merge from the <strong>bug<\/strong> branch to the <strong>master<\/strong> branch. Commit the changes after the merge.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Bug-branch-to-the-Master-branch.png\"><img decoding=\"async\" width=\"723\" height=\"578\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Bug-branch-to-the-Master-branch.png\" alt=\"Bug branch to the Master branch\" class=\"wp-image-109726\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Bug-branch-to-the-Master-branch.png 723w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Bug-branch-to-the-Master-branch-300x240.png 300w\" sizes=\"(max-width: 723px) 100vw, 723px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Status.png\"><img decoding=\"async\" width=\"477\" height=\"86\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Status.png\" alt=\"Git Status\" class=\"wp-image-109727\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Status.png 477w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Status-300x54.png 300w\" sizes=\"(max-width: 477px) 100vw, 477px\" \/><\/a><\/figure>\n\n\n\n<p><span style=\"text-decoration: underline;\"><strong>Example 3:<\/strong><\/span> Working with Multiple Stash.<\/p>\n\n\n\n<p>In the local repo, there are 2 Html files. So, it is possible that multiple developers would work on multiple files and stash changes as needed to work on urgent requests that come their way to fix the changes.<\/p>\n\n\n\n<p>Developer 1 works on hello.html and Developer 2 works on index.html.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Example-3-Working-with-Multiple-stash.png\"><img decoding=\"async\" width=\"581\" height=\"308\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Example-3-Working-with-Multiple-stash.png\" alt=\"Example 3 Working with Multiple stash\" class=\"wp-image-109728\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Example-3-Working-with-Multiple-stash.png 581w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Example-3-Working-with-Multiple-stash-300x159.png 300w\" sizes=\"(max-width: 581px) 100vw, 581px\" \/><\/a><\/figure>\n\n\n\n<p><strong>Developer 1<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Developer-1.png\"><img decoding=\"async\" width=\"740\" height=\"459\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Developer-1.png\" alt=\"Developer 1\" class=\"wp-image-109729\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Developer-1.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Developer-1-300x186.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p>Stash list has 1 entry now.<\/p>\n\n\n\n<p><strong>Developer 2<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Developer-2.png\"><img decoding=\"async\" width=\"740\" height=\"473\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Developer-2.png\" alt=\"Developer 2\" class=\"wp-image-109730\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Developer-2.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Developer-2-300x192.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p>Stash list now has 2 entries. The latest stash is first in the stack which is stash@{0}. Now both the developers can do any other commits urgently or work on some other branch and then come back to the <strong>master <\/strong>branch and apply the stash changes.<\/p>\n\n\n\n<p>To apply the latest stash, you can just run<\/p>\n\n\n\n<p><strong>git stash pop<\/strong><\/p>\n\n\n\n<p>To apply a specific stash in the stack run the following command.<\/p>\n\n\n\n<p><strong>git stash pop stash@{1}<\/strong><\/p>\n\n\n\n<p>Let\u2019s apply the second stash which is <strong>stash@{1}<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Apply-a-specific-stash-in-the-stack.png\"><img decoding=\"async\" width=\"740\" height=\"464\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Apply-a-specific-stash-in-the-stack.png\" alt=\"Apply a specific stash in the stack\" class=\"wp-image-109731\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Apply-a-specific-stash-in-the-stack.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Apply-a-specific-stash-in-the-stack-300x188.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p>Similarly, the other stash can be applied.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span style=\"color: #ff6600;\">Git Cherry Pick<\/span><\/h4>\n\n\n\n<p>Today, the developers work on multiple branches like feature, enhancement, bug, etc.<\/p>\n\n\n\n<p>There are situations where only a couple of specific commits need to be picked and not merge the entire branch into another branch. This is called a Cherry Pick. This process allows you to arbitrarily pick any Git commit from the other branches and append it to the current HEAD of the working tree.<\/p>\n\n\n\n<p><span style=\"text-decoration: underline;\"><strong>Example 1:<\/strong><\/span><\/p>\n\n\n\n<p>In the local git repository, we have the following 6 files.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Cherry-pick-Example-1.png\"><img decoding=\"async\" width=\"577\" height=\"584\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Cherry-pick-Example-1.png\" alt=\"Git Cherry-pick Example 1\" class=\"wp-image-109732\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Cherry-pick-Example-1.png 577w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-Cherry-pick-Example-1-296x300.png 296w\" sizes=\"(max-width: 577px) 100vw, 577px\" \/><\/a><\/figure>\n\n\n\n<p>One file is deleted say file5.txt.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Delete-one-file.png\"><img decoding=\"async\" width=\"310\" height=\"56\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Delete-one-file.png\" alt=\"Delete one file\" class=\"wp-image-109733\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Delete-one-file.png 310w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Delete-one-file-300x54.png 300w\" sizes=\"(max-width: 310px) 100vw, 310px\" \/><\/a><\/figure>\n\n\n\n<p>Commit the changes.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Commit-the-changes-after-delete.png\"><img decoding=\"async\" width=\"740\" height=\"350\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Commit-the-changes-after-delete.png\" alt=\"Commit the changes after delete\" class=\"wp-image-109734\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Commit-the-changes-after-delete.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Commit-the-changes-after-delete-300x142.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p>Look at the log now. File5.txt is deleted.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/File5.txt-is-deleted.png\"><img decoding=\"async\" width=\"596\" height=\"646\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/File5.txt-is-deleted.png\" alt=\"File5.txt is deleted\" class=\"wp-image-109735\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/File5.txt-is-deleted.png 596w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/File5.txt-is-deleted-277x300.png 277w\" sizes=\"(max-width: 596px) 100vw, 596px\" \/><\/a><\/figure>\n\n\n\n<p>So, we want to Cherry-Pick the commit where we added file5.txt. We need to find the commit id of file5.tx and run the command.<\/p>\n\n\n\n<p><strong>git cherry-pick &lt;Commit-Id&gt;<\/strong><\/p>\n\n\n\n<p>In this case, the commit id of when file5.txt was added is <strong>a2f0124<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/file5.txt-was-added-is-a2f0124.png\"><img decoding=\"async\" width=\"581\" height=\"593\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/file5.txt-was-added-is-a2f0124.png\" alt=\"file5.txt was added is a2f0124\" class=\"wp-image-109736\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/file5.txt-was-added-is-a2f0124.png 581w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/file5.txt-was-added-is-a2f0124-294x300.png 294w\" sizes=\"(max-width: 581px) 100vw, 581px\" \/><\/a><\/figure>\n\n\n\n<p>File5.txt is now restored. We Cherry-Picked the commit.<\/p>\n\n\n\n<p><span style=\"text-decoration: underline;\"><strong>Example 2:<\/strong><\/span><\/p>\n\n\n\n<p>Let\u2019s just modify <strong> file6.txt<\/strong> and commit the changes in the <strong>master <\/strong>branch.<\/p>\n\n\n\n<p>Look at the second line in <strong>file6.txt<\/strong> where the email is not specified correctly.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Email-is-not-specified-correctly.png\"><img decoding=\"async\" width=\"192\" height=\"105\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Email-is-not-specified-correctly.png\" alt=\"Email is not specified correctly\" class=\"wp-image-109737\"\/><\/a><\/figure>\n\n\n\n<p>Create a bug branch and fix the issue. At the same time modify file5.txt as well so that we have multiple commits done in the bug branch but will Cherry-Pick only the commit done in file6.txt.<\/p>\n\n\n\n<p>File6 modified in <strong>bug<\/strong> branch.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/File6-modified-in-bug-branch.png\"><img decoding=\"async\" width=\"291\" height=\"107\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/File6-modified-in-bug-branch.png\" alt=\"File6 modified in bug branch\" class=\"wp-image-109738\"\/><\/a><\/figure>\n\n\n\n<p>So, overall, we have done changes to <strong>file5 and file6<\/strong> in the Bug branch.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/changes-to-file5-and-file6.png\"><img decoding=\"async\" width=\"711\" height=\"688\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/changes-to-file5-and-file6.png\" alt=\"changes to file5 and file6\" class=\"wp-image-109739\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/changes-to-file5-and-file6.png 711w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/changes-to-file5-and-file6-300x290.png 300w\" sizes=\"(max-width: 711px) 100vw, 711px\" \/><\/a><\/figure>\n\n\n\n<p>Let\u2019s now switch back to the <strong>master <\/strong>branch and Cherry-Pick the commit done for file6.txt only.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/12\/Back-to-the-master-branch.png\"><img decoding=\"async\" width=\"740\" height=\"207\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/12\/Back-to-the-master-branch.png\" alt=\"Back to the master branch\" class=\"wp-image-114059\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/12\/Back-to-the-master-branch.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/12\/Back-to-the-master-branch-300x84.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p>As you can see that instead of merging the <strong>bug<\/strong> branch into the <strong>master <\/strong>branch, we have just Cherry-Picked only a specific commit and applied in the master branch.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span style=\"color: #ff6600;\">Git Reset<\/span><\/h4>\n\n\n\n<p>Git reset is a powerful command to undo local changes. So, to un-stage, all the staged files this command is used.<\/p>\n\n\n\n<p><span style=\"text-decoration: underline;\"><strong>Example<\/strong><\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Modify-a-file-and-add-it-to-staging.png\"><img decoding=\"async\" width=\"740\" height=\"586\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Modify-a-file-and-add-it-to-staging.png\" alt=\"Modify a file and add it to staging\" class=\"wp-image-109741\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Modify-a-file-and-add-it-to-staging.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Modify-a-file-and-add-it-to-staging-300x238.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p>Modify a file and add it to staging. Reset using the command as shown when the staged changes are unstaged.<\/p>\n\n\n\n<p>Parameters of <strong>git reset<\/strong> command.<\/p>\n\n\n\n<p><strong>&#8211;soft:<\/strong> This parameter will point the HEAD to another commit. All files are changed between the original HEAD and the commit will be staged. The working directory is intact.<\/p>\n\n\n\n<p>Look at the current HEAD location.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Look-at-the-current-HEAD-location.png\"><img decoding=\"async\" width=\"527\" height=\"289\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Look-at-the-current-HEAD-location.png\" alt=\"Look at the current HEAD location\" class=\"wp-image-109742\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Look-at-the-current-HEAD-location.png 527w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Look-at-the-current-HEAD-location-300x165.png 300w\" sizes=\"(max-width: 527px) 100vw, 527px\" \/><\/a><\/figure>\n\n\n\n<p>Let\u2019s go back 5 commits in the history.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Go-back-5-commits.png\"><img decoding=\"async\" width=\"522\" height=\"379\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Go-back-5-commits.png\" alt=\"Go back 5 commits\" class=\"wp-image-109743\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Go-back-5-commits.png 522w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Go-back-5-commits-300x218.png 300w\" sizes=\"(max-width: 522px) 100vw, 522px\" \/><\/a><\/figure>\n\n\n\n<p>Re-Commit the changes.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Re-Commit-the-changes.png\"><img decoding=\"async\" width=\"740\" height=\"285\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Re-Commit-the-changes.png\" alt=\"Re-Commit the changes\" class=\"wp-image-109744\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Re-Commit-the-changes.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Re-Commit-the-changes-300x116.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p><strong>&#8211;mixed:<\/strong> The option is similar to the soft parameter. Usually, when there are some bad commits, you remove them and fix it later and commit it back. So essentially, we need to add to index using <strong>git add<\/strong> and then <strong>git commit.<\/strong> Changes are left in the working tree.<\/p>\n\n\n\n<p>Let\u2019s go back 2 commits in history and see that the files are untracked.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Go-back-2-commits.png\"><img decoding=\"async\" width=\"740\" height=\"372\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Go-back-2-commits.png\" alt=\"Go back 2 commits\" class=\"wp-image-109745\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Go-back-2-commits.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Go-back-2-commits-300x151.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p>Now add the files to staging and commit the changes.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Add-the-files-to-staging-and-commit-changes.png\"><img decoding=\"async\" width=\"597\" height=\"189\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Add-the-files-to-staging-and-commit-changes.png\" alt=\"Add the files to staging and commit changes\" class=\"wp-image-109746\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Add-the-files-to-staging-and-commit-changes.png 597w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Add-the-files-to-staging-and-commit-changes-300x95.png 300w\" sizes=\"(max-width: 597px) 100vw, 597px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-log-oneline.png\"><img decoding=\"async\" width=\"366\" height=\"157\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-log-oneline.png\" alt=\"Git log-oneline\" class=\"wp-image-109747\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-log-oneline.png 366w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Git-log-oneline-300x129.png 300w\" sizes=\"(max-width: 366px) 100vw, 366px\" \/><\/a><\/figure>\n\n\n\n<p><strong>&#8211;hard: <\/strong>This parameter will rest to a point where a particular file existed. The changes will not be available in the working tree.<\/p>\n\n\n\n<p>Looking at the above log lets go back to the point where only file 1 was committed i.e. the last entry.<\/p>\n\n\n\n<p>Using <strong>git reset &#8211;hard &lt;CommitID&gt;<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Using-git-reset-hard-CommitID.png\"><img decoding=\"async\" width=\"577\" height=\"429\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Using-git-reset-hard-CommitID.png\" alt=\"Using git reset-hard (CommitID)\" class=\"wp-image-109748\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Using-git-reset-hard-CommitID.png 577w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Using-git-reset-hard-CommitID-300x223.png 300w\" sizes=\"(max-width: 577px) 100vw, 577px\" \/><\/a><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><span style=\"color: #ff6600;\">Git Bisect<\/span><\/h4>\n\n\n\n<p>Find the exact commit which broke the code (We all are humans after all). Often during testing of the application, we hear from our testers that there is a bug or the feature is broken and you as the developer will say that it worked last week. So, what happened and why did this bug appear?<\/p>\n\n\n\n<p>Sometimes a change in the other code could have impacted your feature. You have to spend time going through the history where there are lots of commits that is time-consuming and hard to track which change caused the code to break.<\/p>\n\n\n\n<p><strong>Git Bisect <\/strong>is the command to find the exact commit when the bug was introduced. With Git bisect you need to pick two commits, one good and one bad. About halfway between both commits will be checked out. You check each commit either bad or good until the commit that caused the bug or code to break is found.<\/p>\n\n\n\n<p><span style=\"text-decoration: underline;\"><strong>Example:<\/strong><\/span><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create a new local git repository and create a file called index.html<\/li>\n\n\n\n<li>Initial contents of the file as shown.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Initial-contents-of-the-file.png\"><img decoding=\"async\" width=\"550\" height=\"279\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Initial-contents-of-the-file.png\" alt=\"Initial contents of the file\" class=\"wp-image-109750\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Initial-contents-of-the-file.png 550w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Initial-contents-of-the-file-300x152.png 300w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add to staging and commit to the repository.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Add-to-staging-and-commit-to-repository.png\"><img decoding=\"async\" width=\"690\" height=\"404\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Add-to-staging-and-commit-to-repository.png\" alt=\"Add to staging and commit to repository\" class=\"wp-image-109751\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Add-to-staging-and-commit-to-repository.png 690w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Add-to-staging-and-commit-to-repository-300x176.png 300w\" sizes=\"(max-width: 690px) 100vw, 690px\" \/><\/a><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create a history of commits as shown, so that we can choose between good and bad commits. Now as the initial commit is done do the other changes as shown and commit the same. Overall, we will do 7 commits.<\/li>\n<\/ul>\n\n\n\n<p><strong>Second Change<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Second-change.png\"><img decoding=\"async\" width=\"540\" height=\"295\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Second-change.png\" alt=\"Second change\" class=\"wp-image-109753\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Second-change.png 540w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Second-change-300x164.png 300w\" sizes=\"(max-width: 540px) 100vw, 540px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Second-change-Initial-Commit.png\"><img decoding=\"async\" width=\"555\" height=\"330\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Second-change-Initial-Commit.png\" alt=\"Second change Initial Commit\" class=\"wp-image-109754\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Second-change-Initial-Commit.png 555w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Second-change-Initial-Commit-300x178.png 300w\" sizes=\"(max-width: 555px) 100vw, 555px\" \/><\/a><\/figure>\n\n\n\n<p><strong> Third Change<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Third-Change.png\"><img decoding=\"async\" width=\"540\" height=\"247\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Third-Change.png\" alt=\"Third Change\" class=\"wp-image-109755\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Third-Change.png 540w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Third-Change-300x137.png 300w\" sizes=\"(max-width: 540px) 100vw, 540px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Third-Change-initial-commit.png\"><img decoding=\"async\" width=\"539\" height=\"354\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Third-Change-initial-commit.png\" alt=\"Third Change initial commit\" class=\"wp-image-109756\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Third-Change-initial-commit.png 539w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Third-Change-initial-commit-300x197.png 300w\" sizes=\"(max-width: 539px) 100vw, 539px\" \/><\/a><\/figure>\n\n\n\n<p><strong>Fourth Change<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Fourth-Change.png\"><img decoding=\"async\" width=\"540\" height=\"273\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Fourth-Change.png\" alt=\"Fourth Change\" class=\"wp-image-109757\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Fourth-Change.png 540w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Fourth-Change-300x152.png 300w\" sizes=\"(max-width: 540px) 100vw, 540px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Fourth-Change-Initial-commit.png\"><img decoding=\"async\" width=\"544\" height=\"376\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Fourth-Change-Initial-commit.png\" alt=\"Fourth Change Initial commit\" class=\"wp-image-109758\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Fourth-Change-Initial-commit.png 544w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Fourth-Change-Initial-commit-300x207.png 300w\" sizes=\"(max-width: 544px) 100vw, 544px\" \/><\/a><\/figure>\n\n\n\n<p><strong>Fifth Change<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Fifth-Change.png\"><img decoding=\"async\" width=\"540\" height=\"296\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Fifth-Change.png\" alt=\"Fifth Change\" class=\"wp-image-109759\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Fifth-Change.png 540w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Fifth-Change-300x164.png 300w\" sizes=\"(max-width: 540px) 100vw, 540px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Fifth-Change-Initial-Commit.png\"><img decoding=\"async\" width=\"544\" height=\"402\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Fifth-Change-Initial-Commit.png\" alt=\"Fifth Change Initial Commit\" class=\"wp-image-109760\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Fifth-Change-Initial-Commit.png 544w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Fifth-Change-Initial-Commit-300x222.png 300w\" sizes=\"(max-width: 544px) 100vw, 544px\" \/><\/a><\/figure>\n\n\n\n<p><strong>Sixth Change<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Sixth-Change.png\"><img decoding=\"async\" width=\"540\" height=\"319\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Sixth-Change.png\" alt=\"Sixth Change\" class=\"wp-image-109761\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Sixth-Change.png 540w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Sixth-Change-300x177.png 300w\" sizes=\"(max-width: 540px) 100vw, 540px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Sixth-Change-initial-Commit.png\"><img decoding=\"async\" width=\"537\" height=\"430\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Sixth-Change-initial-Commit.png\" alt=\"Sixth Change initial Commit\" class=\"wp-image-109762\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Sixth-Change-initial-Commit.png 537w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Sixth-Change-initial-Commit-300x240.png 300w\" sizes=\"(max-width: 537px) 100vw, 537px\" \/><\/a><\/figure>\n\n\n\n<p><strong>Seventh Change<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Seventh-Change.png\"><img decoding=\"async\" width=\"545\" height=\"339\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Seventh-Change.png\" alt=\"Seventh Change\" class=\"wp-image-109763\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Seventh-Change.png 545w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Seventh-Change-300x187.png 300w\" sizes=\"(max-width: 545px) 100vw, 545px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Seventh-Change-Initial-Commit.png\"><img decoding=\"async\" width=\"556\" height=\"452\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Seventh-Change-Initial-Commit.png\" alt=\"Seventh Change Initial Commit\" class=\"wp-image-109764\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Seventh-Change-Initial-Commit.png 556w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Seventh-Change-Initial-Commit-300x244.png 300w\" sizes=\"(max-width: 556px) 100vw, 556px\" \/><\/a><\/figure>\n\n\n\n<p>Let\u2019s stop here. So, we have seven commits.<\/p>\n\n\n\n<p>If you look at the Html page, the lines after \u201cAll the 4 events \u2026 \u201care wrong and thus the documentation is not correct. So, we need to find the commit where the error was introduced so that we can rest our HEAD to that commit.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Need-to-find-the-commit-with-error.png\"><img decoding=\"async\" width=\"302\" height=\"269\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Need-to-find-the-commit-with-error.png\" alt=\"Need to find the commit with error\" class=\"wp-image-109765\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Need-to-find-the-commit-with-error.png 302w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Need-to-find-the-commit-with-error-300x267.png 300w\" sizes=\"(max-width: 302px) 100vw, 302px\" \/><\/a><\/figure>\n\n\n\n<p>Let\u2019s look at the log and find out the <strong>bad <\/strong>and<strong> good commit.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Bad-and-good-commit.png\"><img decoding=\"async\" width=\"454\" height=\"215\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Bad-and-good-commit.png\" alt=\"Bad and good commit\" class=\"wp-image-109766\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Bad-and-good-commit.png 454w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Bad-and-good-commit-300x142.png 300w\" sizes=\"(max-width: 454px) 100vw, 454px\" \/><\/a><\/figure>\n\n\n\n<p>The latest commit is not right, so it can be a bad commit. The commit was introduced after the third commit, so we can have the <strong>Third Change <\/strong>as the good commit.<\/p>\n\n\n\n<p>The process of bisecting starts with <strong>git bisect start<\/strong> and ends with <strong>git bisect reset.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Process-of-bisecting.png\"><img decoding=\"async\" width=\"696\" height=\"445\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Process-of-bisecting.png\" alt=\"Process of bisecting\" class=\"wp-image-109767\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Process-of-bisecting.png 696w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Process-of-bisecting-300x192.png 300w\" sizes=\"(max-width: 696px) 100vw, 696px\" \/><\/a><\/figure>\n\n\n\n<p><strong>git bisect bad<\/strong> \/\/ As latest commit is bad. No need to provide the commit id.<\/p>\n\n\n\n<p><strong>git bisect good &lt;Commit Id of third change&gt;<\/strong><\/p>\n\n\n\n<p>You can now see that HEAD is now in between half of the bad and good commit.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Half-way-of-bad-and-good-commit.png\"><img decoding=\"async\" width=\"417\" height=\"171\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Half-way-of-bad-and-good-commit.png\" alt=\"Half way of bad and good commit\" class=\"wp-image-109768\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Half-way-of-bad-and-good-commit.png 417w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Half-way-of-bad-and-good-commit-300x123.png 300w\" sizes=\"(max-width: 417px) 100vw, 417px\" \/><\/a><\/figure>\n\n\n\n<p>Look at the content of index.html and see if there is a good commit. If not, then the error is still not found.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Look-at-the-content-of-index.html.png\"><img decoding=\"async\" width=\"583\" height=\"380\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Look-at-the-content-of-index.html.png\" alt=\"Look at the content of index.html\" class=\"wp-image-109769\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Look-at-the-content-of-index.html.png 583w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Look-at-the-content-of-index.html-300x196.png 300w\" sizes=\"(max-width: 583px) 100vw, 583px\" \/><\/a><\/figure>\n\n\n\n<p>Not really that the error still exists. The last line is wrong. So, we run \u2018<strong>git bisect bad\u2019. <\/strong>There is still a bad commit and the current content is not acceptable.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Run-\u2018git-bisect-bad\u2019.png\"><img decoding=\"async\" width=\"712\" height=\"442\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Run-\u2018git-bisect-bad\u2019.png\" alt=\"Run \u2018git bisect bad\u2019\" class=\"wp-image-109770\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Run-\u2018git-bisect-bad\u2019.png 712w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Run-\u2018git-bisect-bad\u2019-300x186.png 300w\" sizes=\"(max-width: 712px) 100vw, 712px\" \/><\/a><\/figure>\n\n\n\n<p>The above content is correct and acceptable.<\/p>\n\n\n\n<p>Run \u2018git log &#8211;oneline\u2019 and \u2018git bisect good\u2019.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Run-\u2018git-log-oneline\u2019-and-\u2018git-bisect-good\u2019.png\"><img decoding=\"async\" width=\"740\" height=\"236\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Run-\u2018git-log-oneline\u2019-and-\u2018git-bisect-good\u2019.png\" alt=\"Run \u2018git log --oneline\u2019 and \u2018git bisect good\u2019\" class=\"wp-image-109771\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Run-\u2018git-log-oneline\u2019-and-\u2018git-bisect-good\u2019.png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Run-\u2018git-log-oneline\u2019-and-\u2018git-bisect-good\u2019-300x96.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<p>So, the <strong>Fifth Change <\/strong>was the first bad commit and truly so. The error is identified.<\/p>\n\n\n\n<p>The current content should be in the final documentation.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/final-documentation.png\"><img decoding=\"async\" width=\"583\" height=\"320\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/final-documentation.png\" alt=\"final documentation\" class=\"wp-image-109772\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/final-documentation.png 583w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/final-documentation-300x165.png 300w\" sizes=\"(max-width: 583px) 100vw, 583px\" \/><\/a><\/figure>\n\n\n\n<p>As the bad commit is identified you can inform the developer to correct the changes that may be to reset the head to the fourth change which was the last good commit.<\/p>\n\n\n\n<p>Run \u2018<strong>git bisect reset<\/strong>\u2019 to end the process.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Run-\u2018git-bisect-reset\u2019-to-end-the-process..png\"><img decoding=\"async\" width=\"740\" height=\"395\" src=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Run-\u2018git-bisect-reset\u2019-to-end-the-process..png\" alt=\"Run \u2018git bisect reset\u2019 to end the process.\" class=\"wp-image-109773\" srcset=\"https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Run-\u2018git-bisect-reset\u2019-to-end-the-process..png 740w, https:\/\/www.softwaretestinghelp.com\/wp-content\/qa\/uploads\/2019\/11\/Run-\u2018git-bisect-reset\u2019-to-end-the-process.-300x160.png 300w\" sizes=\"(max-width: 740px) 100vw, 740px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusion<\/h3>\n\n\n\n<p>In this GitHub hands-on primer, we have tried to cover all that a developer would need to work on i.e. from version control and tracking point of view.<\/p>\n\n\n\n<p>In the first three tutorials of the GitHub series we have learned about version control activities, creating repositories, pull request, branches, code reviews, organizations &amp; teams, fork a repository, labels, milestones, issues, project boards, wikis, releases, integration with Jira and some commonly used Git commands for developers.<\/p>\n\n\n\n<p>We truly hope that all the developers would find this hands-on approach for GitHub and the Git commands useful in their projects.<\/p>\n\n\n\n<p><strong>=&gt; <a href=\"https:\/\/www.softwaretestinghelp.com\/github-tutorial\/\">Read Through The Easy GitHub Training Series.<\/a><\/strong><\/p>\n\r\n\t\t\t<div id=\"daexthefup-container\"\r\n\t\t\t\tclass=\"daexthefup-container daexthefup-layout-stacked daexthefup-alignment-center\"\r\n\t\t\t\tdata-post-id=\"109666\">\r\n\r\n\t\t\t\t<div class=\"daexthefup-feedback\">\r\n\t\t\t\t\t<div class=\"daexthefup-text\">\r\n\t\t\t\t\t\t<h3 class=\"daexthefup-title\">Was this helpful?<\/h3>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<div class=\"daexthefup-buttons-container\">\r\n\t\t\t\t\t\t<div class=\"daexthefup-buttons\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t<div class=\"daexthefup-yes daexthefup-button daexthefup-button-type-icon\" data-value=\"1\">\r\n\t\t\t\t\r\n                <svg>\r\n                    <defs>\r\n                        <style>.thumb-up-cls-1{fill:#c9c9c9;}.thumb-up-cls-2{fill:#e1e1e1;}.thumb-up-cls-3{fill:#676767;}<\/style>\r\n                    <\/defs>\r\n                    <g id=\"thumb_up\">\r\n                        <path class=\"thumb-up-cls-2 daexthefup-icon-circle\" d=\"m24,3c11.58,0,21,9.42,21,21s-9.42,21-21,21S3,35.58,3,24,12.42,3,24,3m0-1C11.85,2,2,11.85,2,24s9.85,22,22,22,22-9.85,22-22S36.15,2,24,2h0Z\" \/>\r\n                        <g>\r\n                            <rect class=\"thumb-up-cls-3 daexthefup-icon-secondary-color\" x=\"10\" y=\"20\" width=\"6\" height=\"15\" rx=\"1.5\" ry=\"1.5\" \/>\r\n                            <path class=\"thumb-up-cls-1 daexthefup-icon-primary-color\" d=\"m30.57,9.06l-.49-.1c-.81-.17-1.61.35-1.78,1.16l-5.3,11.74c-.17.81,3.16,1.61,3.97,1.78l1.96.41c.81.17,1.61-.35,1.78-1.16l2.18-10.27c.34-1.61-.7-3.21-2.31-3.56Z\" \/>\r\n                            <path class=\"thumb-up-cls-1 daexthefup-icon-primary-color\" d=\"m38.17,20h-18.67c-.83,0-1.5.67-1.5,1.5v12c0,.83.67,1.5,1.5,1.5h16.27c.71,0,1.33-.5,1.47-1.21l2.4-12c.19-.93-.53-1.8-1.47-1.8Z\" \/>\r\n                        <\/g>\r\n                    <\/g>\r\n                <\/svg>\t\t\t<\/div>\r\n\r\n\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t<div class=\"daexthefup-no daexthefup-button daexthefup-button-type-icon\" data-value=\"0\">\r\n\t\t\t\t\r\n                <svg>\r\n                    <defs>\r\n                        <style>.thumb-down-cls-1{fill:#c9c9c9;}.thumb-down-cls-2{fill:#e1e1e1;}.thumb-down-cls-3{fill:#676767;}<\/style>\r\n                    <\/defs>\r\n                    <g id=\"thumb_down\">\r\n                        <path class=\"thumb-down-cls-2 daexthefup-icon-circle\" d=\"m24,3c11.58,0,21,9.42,21,21s-9.42,21-21,21S3,35.58,3,24,12.42,3,24,3m0-1C11.85,2,2,11.85,2,24s9.85,22,22,22,22-9.85,22-22S36.15,2,24,2h0Z\" \/>\r\n                        <g>\r\n                            <rect class=\"thumb-down-cls-3 daexthefup-icon-secondary-color\" x=\"10\" y=\"13\" width=\"6\" height=\"15\" rx=\"1.5\" ry=\"1.5\" \/>\r\n                            <path class=\"thumb-down-cls-1 daexthefup-icon-primary-color\" d=\"m30.57,38.94l-.49.1c-.81.17-1.61-.35-1.78-1.16l-5.3-11.74c-.17-.81,3.16-1.61,3.97-1.78l1.96-.41c.81-.17,1.61.35,1.78,1.16l2.18,10.27c.34,1.61-.7,3.21-2.31,3.56Z\" \/>\r\n                            <path class=\"thumb-down-cls-1 daexthefup-icon-primary-color\" d=\"m38.17,28h-18.67c-.83,0-1.5-.67-1.5-1.5v-12c0-.83.67-1.5,1.5-1.5h16.27c.71,0,1.33.5,1.47,1.21l2.4,12c.19.93-.53,1.8-1.47,1.8Z\" \/>\r\n                        <\/g>\r\n                    <\/g>\r\n                <\/svg>\t\t\t<\/div>\r\n\r\n\t\t\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t<\/div>\r\n\r\n\t\t\t\t<div class=\"daexthefup-comment\">\r\n\t\t\t\t\t<div class=\"daexthefup-comment-top-container\">\r\n\t\t\t\t\t\t<label id=\"daexthefup-comment-label\" class=\"daexthefup-comment-label\"><\/label>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"daexthefup-comment-character-counter-container\">\r\n\t\t\t\t\t\t\t\t<div id=\"daexthefup-comment-character-counter-number\"\r\n\t\t\t\t\t\t\t\t\tclass=\"daexthefup-comment-character-counter-number\"><\/div>\r\n\t\t\t\t\t\t\t\t<div class=\"daexthefup-comment-character-counter-text\"><\/div>\r\n\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t<\/div>\r\n\t\t\t\t\t<textarea id=\"daexthefup-comment-textarea\" class=\"daexthefup-comment-textarea\"\r\n\t\t\t\t\t\t\t\tplaceholder=\"Type your message\"\r\n\t\t\t\t\t\t\t\tmaxlength=\"\r\n\t\t\t\t\t\t\t\t400\t\t\t\t\t\t\t\t\t\"><\/textarea>\r\n\t\t\t\t\t<div class=\"daexthefup-comment-buttons-container\">\r\n\t\t\t\t\t\t<button class=\"daexthefup-comment-submit daexthefup-button\">Submit<\/button>\r\n\t\t\t\t\t\t<button class=\"daexthefup-comment-cancel daexthefup-button\">Cancel<\/button>\r\n\t\t\t\t\t<\/div>\r\n\t\t\t\t<\/div>\r\n\r\n\t\t\t\t<div class=\"daexthefup-successful-submission-text\">Thanks for your feedback!<\/div>\r\n\r\n\t\t\t<\/div>\r\n\r\n\t\t\t","protected":false},"excerpt":{"rendered":"<p>This Tutorial Explores Useful Git Commands such as Git Stash, Git Reset, Git Cherry Pick, Git Bisect &amp; Explains how to Integrate GitHub with Jira: In our previous tutorials in this series, we have seen most of the features of GitHub. In this tutorial, we will look at the following: &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Advanced Git Commands And GitHub Integration Tutorial\" class=\"read-more button\" href=\"https:\/\/www.softwaretestinghelp.com\/advanced-git-commands\/#more-109666\" aria-label=\"Read more about Advanced Git Commands And GitHub Integration Tutorial\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":110117,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_helpful_pro_status":1,"footnotes":""},"categories":[593],"tags":[],"class_list":{"0":"post-109666","1":"page","2":"type-page","3":"status-publish","4":"has-post-thumbnail","6":"category-github"},"acf":[],"_links":{"self":[{"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/pages\/109666","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/comments?post=109666"}],"version-history":[{"count":0,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/pages\/109666\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/media\/110117"}],"wp:attachment":[{"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/media?parent=109666"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/categories?post=109666"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.softwaretestinghelp.com\/wp-json\/wp\/v2\/tags?post=109666"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}