GithubHelp home page GithubHelp logo

conflict-demo's Introduction

Conflict Demo

Let's create a conflict

  1. Starting from the master branch, create two new branches, red and blue.

    git branch red
    git branch blue
    
  2. Switch to the red branch, change the color to red, and commit.

    git checkout red
    # change the color in the css file...
    git add style.css
    git commit -m 'Change background to red'
    
  3. Switch to the blue branch and change the color to blue.

    git checkout blue
    # change the color in the css file...
    git add style.css
    git commit -m 'Change background to blue'
    
  4. Switch back to master and merge the branches

    git checkout master
    git merge red
    git merge blue
    
  5. We should now have a merge conflict!

  6. Open up the style.css file and look around. Solve the merge conflict.

    Git will place markers in the file that indicate where the merge conflict is. To resolve the conflict, remove these markers, and decide which version of the code you want to use. This usually means pairing with a teammate and talking about which changes to use, or how to integrate the two sets of changes.

    See also the commands below.

  7. Mark the conflicts as resolved

    git add style.css
    
  8. Conclude the merge

    git commit
    

Commands

Just use our version of the file

git checkout --ours style.css

Use their version of the file

git checkout --theirs style.css

Discard any changes to the file and re-create the original conflicted merge result

git checkout -m style.css

Abort the merge

git merge --abort

Notes

  • Make sure you've added and committed any work before attempting a merge!

    If you have uncommited changes and you try to merge, then back out of the merge (git merge --abort), you could potentially lose your work.

conflict-demo's People

Contributors

zgulde avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.