[RUBY] How to resolve Git conflicts

It's a phenomenon that almost always happens when we are co-developing! Lol If you don't panic and calm down, there will be no problem, so it's okay. Let's go! !!

Contents

スクリーンショット 2020-12-13 20.42.52.png

procedure

Update master (merge destination) Switch branches

$ git checkout master

Reflect the remote status
$ git pull 

Return to the working branch

$git checkout working branch name

Do the following:

$ git fetch
$ git merge origin/master

Then it will let you know that there is a conflict.

Auto-merging db/schema.rb
CONFLICT (content): Merge conflict in db/schema.rb
Auto-merging config/routes.rb
Auto-merging app/views/layouts/application.html.erb
CONFLICT (content): Merge conflict in app/views/layouts/application.html.erb
Auto-merging app/assets/stylesheets/application.scss
CONFLICT (content): Merge conflict in app/assets/stylesheets/application.scss
Automatic merge failed; fix conflicts and then commit the result.

Let's take a look at where the conflict is occurring!

CONFLICT (content): Merge conflict in app/views/layouts/application.html.erb

スクリーンショット 2020-12-13 20.47.24.png

When you open the editor, it will be displayed in purple, so it will be easy to understand. (Using vscode)

<<<<<<< HEAD
#Changes in the working branch
・ ・ ・
=======
# origin/master(Merged branch)Changes in
・ ・ ・
>>>>>>> origin/master

Leave master (latest) and delete the contents of your working branch

Don't forget to delete this too!
<<<<<<< HEAD

=======

>>>>>>> origin/master

When the correction of the part where the conflict occurs is completed Commit and push

git commit -m "Conflict resolution"

git push origin working branch name
This is ok. ww

Recommended Posts

How to resolve Git conflicts
How to resolve Mixed Content errors
[Technical memo] How to resolve errors
How to resolve errors when doing git push heroku master
How to detect microphone conflicts on Android
How to deploy
How to resolve errors when installing Rails 5.1.3
[Servlet / Ajax] How to resolve NoClassDefFoundError [Eclipse]
Git and GitHub ~ How to fix common errors ~
How to call AmazonSQSAsync
How to use Map
How to write Rails
How to use rbenv
How to use letter_opener_web
How to use with_option
How to use fields_for
How to use java.util.logging
How to use map
How to use collection_select
How to adapt Bootstrap
How to use Twitter4J
How to use active_hash! !!
How to install Docker
How to use MapStruct
How to use hidden_field_tag
How to use TreeSet
How to write dockerfile
How to uninstall Rails
How to install docker-machine
[How to use label]
How to make shaded-jar
How to write docker-compose
How to use identity
How to use hashes
How to write Mockito
How to create docker-compose
How to use JUnit 5
How to install MySQL
How to write migrationfile
How to build android-midi-lib
How to use Dozer.mapper
How to use Gradle
How to use org.immutables
How to use java.util.stream.Collector
How to use VisualVM
How to use Map
How to install ngrok
How to type backslash \
How to concatenate strings
How to Git manage Java EE projects in Eclipse
How to resolve SSL_connect error in PayPal Ruby SDK
How to delete BOM (UTF-8)
[Java] How to use Map
[rails] How to post images
[AWS] How to check logs
How to use Chain API
How to lower java version
[Java] How to use Map
How to use Priority Queuing
How to uninstall Java 8 (Mac)
How to write good code