Skip to content

Create a poem #5

@lakruzz

Description

@lakruzz
  • Run the commands that creates the poem
  • Run the commands that creates the branches
  • Create a setting in your team's .gitconfig that makes current the default push strategy
  • Push all your changes (hint there at three new branches! - and a tag!)

One of the most important reasons for using git is its ability to merge files - it's the number one collaboration tool in our industry.

I makes sense to study and understand exactly what a git merge is.

Three-way-merge

Git uses (default) a standard three-way-merge when it merges files.

It's a simple algorithm.

  • Two (2) files must be merged
  • They have a (1) common ancestor - 2+1=3 - hence the name - three-way--merge
  • Each contributing file is line-by-line compared against the common ancestor
  • Change rules if one of the contributors has either deleted, added or altered a line in the file, then that change also goes into the result.
  • If both contributors have different opinions about the same line - then it's a conflict

Let's stir the pot and potentially create a conflict - which we can then solve.

  • Create a directory in the root of the repository called merge-lab
  • Add a file poem.txt with the following poem:
    Eeny, meeny, miny, moe,
    Catch a tiger by the toe.
    If he hollers, let him go,
    Eeny, meeny, miny, moe.
    
    My mother told me to pick 
    the very best one and you - are - it!" 
    
  • Use the git CLI to add and commit the poem to git.
  • Use git tag to create a tag named ancestor
  • Use git push to push it to GitHub - make sure that the also the tag is pushed!

After you have seen it on GitHub go back to the file and make a change to the file.

  • Change the enden exclamation mark ! to a puntuation .
  • use git CLI to add, commit, push.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions