DevOps Classroomnotes 22/Feb/2023

Git Branching

  • Create a new folder and make it a repository
  • add one commit and rename the default branch to main
    Preview
  • create one more commit on main
    Preview
  • Lets create a branch called as sprint0
    Preview
  • lets make one change in sprint0 in src/main.py
    Preview

Fast Forward Merge

  • We want changes done in sprint0 to be merged to main
  • The merge command is git merge <source-branch> i.e. you should be in target branch
    Preview
  • Fast forward merge happened which moves the main to the latest commit of sprint 0 branch.
  • Before Merge
    Preview
  • After Merge
    Preview

Three Way Merge

  • Lets create a commit on main branch and git graph should be as shown below
    Preview
  • Current view
    Preview
  • Lets merge the changes into main
    Preview
  • We get merge conflict as line 1 of src/main.py is conflicting
  • now make the changes and add them to staging area and commit to create a merge commit
    Preview
  • Merge commit is a special commit, which has two parents
  • note: IF you are new to vi editor Refer Here

Exercise

  • Create a git repository
  • create three files called as README.md in
    • src
    • test
    • build
  • create a commit
  • create one more commit by editing README.md in src
  • main will have two commits
  • represent this in graph with HEAD and master in the graph
  • Now create a branch sprint0 from master
  • From sprint0 create two branches
    • sprint0_poc
    • sprint0_dev
  • Update the same in graph
  • Now checkout to sprint0_poc and create a folder called as poc with Readme.me, update the graph
  • Now checkout to sprint0_dev and create a file src/main.py
  • merge changes from sprint0_poc tp sprint0_dev
  • Delete the sprint0_dev

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About continuous learner

devops & cloud enthusiastic learner