![]() ![]() ![]() Switch to feature branch and create a new commit by editing second line in hello.txt file $ MINGW64 /e/tut_repo (master) Initialized empty Git repository in E:/tut_repo/.git/ Step 1 − Create a repository with initial commit with hello.txt file. Let us see this in action to understand how to abort a merge conflict. Now if we abort the merge conflict we will get back to the state before the conflict as shown in the diagram. When we merge the feature branch with the master branch, we will end up with a merge conflict error. ![]() ![]() There are two branches, master and feature, and each one is operating on the same file. We can understand this from the below diagram. Once the command is fired, we are back to the clean state i.e., the state before we started the merge. Note that if we execute this command after resolving some conflicts and staging the changes, then these changes would not be saved. To abort the merge, we can use the following command $ git merge -abort In situations like this we can easily go back to the state before we started the merge. Perhaps you have several conflicts and you don't have enough time to spend on resolving these conflicts. Now what if we are not quite ready to handle this conflict yet. So, for this example Im going to keep both changes, but in a real project you need to be very careful of what lines of code you are moving to not damage the code of another coworker.When doing a merge, you may run into one or more conflicts. Note 2: Don’t worry If you see in your terminal a commit number instead of the name of your actual branch, this is because the “ rebase go through every commit that is in our base branch trying to merge each commit to our actual branch” Note 1: “<<<<<<< HEAD” to line 16 “=” means that this code is on main branch, and the line 16 through line 22 are the changes that we did. Note: you can configure your default editor code Solving the conflictsĪfter click the “Open in Visual Studio Code” button you will see how the Visual studio code will be opened automatically and will show you the file that have a conflict: The modal show us that we have conflicts in 3 different files, so we can start fixing those issues clicking the next button: Making a git rebase through GitHub Desktop:ġ.- Go to main branch and pull the changes, type: git pullĢ.- Open your GitHub Desktop (add your repository) and click on next steps:Īfter you click the button, you will see the next modal: Note: this happen because Cristina and Carlos were woking on the same file and line of code.ġ.- Update his branch (feature/carlos-branch) with the changes that main branch have, this can be possible using git rebase.Ģ.-He need to resolve the conflicts that his branch have (feature/carlos-branch), this can be solved using a tool called GitHub desktop. Then Carlos is reviewing his PR and say: Oh my PR have conflicts! □ Let’s suppose that 2 developers (Cristina y Carlos) are in the same project and then both already created their PR’S:Ĭristina was working on App.js and index.css and also Carlos was working on App.js and index.css (same files, same lines), so here the PR’S:Īnd now she merge her PR to main branch, without issues! □ Hi in this post I’m going to show you how to do a rebase and use the GitHub Desktop to solve code conflicts. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |