DevOps Classroomnotes 30/Apr/2022

Git Contd…

  • In the last session we discussed about merge where a new commit was created with two parents, this is generally referred as three-way-merge
  • Cherry picking was done on once commit i.e. we added one commit from one branch to other branch (without merging)
  • Cherry picking can also done on sequence of commits
  • Lets create a feature_1003 branch with 4 commits in it
  • Now if we merge the changes back to rel_tata_v1.0, by default it creates a fast-forward merge, if your organization follows a practice that whenever you merge we need a commit for that, we can create an extra commit (three way merge) by adding (–no-ff)
    Preview
    Preview
  • Now lets move to the feature_1003 branch
    Preview
  • Now we want all of this 4 commits on rel_wipro_v1.0, so lets cherry-pick range of commits
    Preview
    Preview
    Preview

Special Characters used in Git

  • In Git we would be using
  • Tilde ~:
    • to go back a number of generations
  • Caret ^
  • double dot ..

Exercise:

  • Create a new git repository
  • Try to create a branch and create a situation for merge conflict
  • Try to create a situation for merge without a conflict.

Rebase

  • Consider the following situation
    Preview
  • We need the changes done in master branch after feature branch creation to be part of feature branch, the best way to do it would be as shown graphically below
    Preview
  • Git rebase can exactly do this.
  • Consider the following situation
    Preview
  • Now we want changes of master to be part of feature_branches history
    Preview
  • Now execute git rebase <source branch>
    Preview
    Preview

Lets visit the Three areas of Git (Local Repo)

Preview

Manipulating History

  • Mistakes in previous commit message
    • situation
      Preview
    • solution
      Preview
      Preview
      Preview
  • reflog:
    • Git keeps track of the updates to the tip of branch using a mechanism called as reference logs or reflog
      Preview
  • RESET:
    • Git reset has three modes: soft, mixed and hard
    • Soft Reset:
      • consider the following changes
        Preview
      • Now lets soft reset to second commit
        Preview
        Preview
      • Changes are not lost
    • Hard Reset:
      • Consider the following changes
        Preview
        Preview
      • Changes are lost
    • Mixed Reset:
    • Consider the following changes
      Preview
    • Changes are moved to the working tree (unstaged)
      Preview
    • Changes are not lost

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

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

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube