Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • Toggle search form

Git Tutorial 23 – Git Stash Apply – How To Solve Merge Conflict

Posted on 02/19/2025 By admin

As a part of GIT Tutorials End To End, we will learn about Solving merge conflict during Git Stash apply command in this post.

I will expect that you are aware of the basic concepts and commands of GIT. But if you are a beginner in GIT then I strongly recommend you to refer GIT Basic Commands and Concepts section on my blog first.

Did you know that I have started a YouTube channel as well and I need your support to make it successful. Please do watch content then comment, like, share, and obviously subscribe.

You must learn about the Git stash command from here.

Yes, we can get merge conflict while applying stash. Let’s see it in action.

Just initialized a git repository below-

Let’s create a file, add some content to it and commit it. Please note we must have a commit before we can use git stash the first time.

Now we have a clean working tree. We will perform some steps so that we will experience a merge conflict.

  1. Append contents in FileA.
  2. Stash changes.
  3. Append contents in FileA again
  4. Apply stash changes

All above steps are shown below-

We have uncommitted changes above so when we tried to apply git stash it gave an error shown above. In fact, when we try to apply a stash, a merge happens. Let’s commit changes and retry applying stash.

Now we see the merge conflict which is the topic of this post. The FileA has a text “Added line 3” at the second line which was added recently. While in stashed change, the FileA has a text “Added line 2” at the second line. Now when git tries to merge stashed changes with the current state of FileA, it confused which line to be kept at the second line or to keep both or to remove both. When git confuses then it will surrender and ask you to resolve it manually. Remember there is no magic to solve merge conflicts. We need to put effort manually which we will see now.

Let’s see what is the current content of FileA now.

Conflict changes will be shown as above. Contents are shown from current commit between are from stashed changes. Now you decide what contents you want to keep. You can keep either changes or both.

If you are good in Linux command to edit a file then use it or simply open the file in explorer and resolve.

Before

After – I just kept both changes. It really depends on what changes you want to keep.

We have successfully applied stash changes by solving merge conflicts.

  1. Appling stash is a king of merge operation.
  2. Git stash apply can have merge conflicts.
  3. Merge conflict happens when more than one developers changes the same file at same line. There might be many other reasons.
  4. Resolving merge colflicts may be complex if it is huge and you are not in sync with other’s changes.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe to my YouTube channel.
#ThanksForReading
#HappyLearning

Uncategorized

Post navigation

Previous Post: Interview Experience at Harman Connected Services Bangalore for Selenium Automation Testing Profile – Oct-2019
Next Post: TestNG Tutorials 7: How To Create Customized TestNG XML?

Related Posts

February 15, 2019 – Make Selenium Easy Uncategorized
#1. Java Program To Check Equality Of Two Arrays Uncategorized
image – Make Selenium Easy Uncategorized
TestNGMain – Make Selenium Easy Uncategorized
URL Loading in Selenium Webdriver: All about get() and navigate() | Make Selenium Easy Uncategorized
Handling Browser Window In Selenium Webdriver Uncategorized

Recent Posts

  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing
  • Baby Steps To Become Efficient Selenium-Java Automation Tester
  • Features of Selenium 4.0.0 Release – Java Binding
  • Part 1: Handling Drop-down Created Using SELECT Tag In Selenium

Recent Comments

No comments to show.

Archives

  • April 2026
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • December 2023
  • October 2023
  • August 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • October 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • May 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • January 2018

Categories

  • Getting Started
  • Uncategorized

Copyright © 2026 Make Selenium Easy.

Powered by PressBook Masonry Dark