DevOps Classroom Series – 19/Sept/2020

Story of a organization Learning Thoughts

  • LT has a product LT-HRMS Preview

  • LT has the

    • Management Team
    • Sales Team
    • Research & Development
      • Architecture
      • Development
      • Testing
      • IT Infra Team Preview
  • LT HRMS product is developed, It can be customized. LT HRMS has got a deal from two different customers with some different customizations. There are some other customers in pipeline Preview

  • Now we have three project created

    1. Customer Apple
    2. Customer Amazon
    3. Core Features
  • How should we handle code repository for these situations. To handle parallel tracks in projects we generally create branch Preview

  • Branches in version controls allows to merge changes from one branch to other.

  • How do i create a branch in git

    • Git already has default branch master
    • Git Branch is a pointer which looks at latest commit.
  • HEAD is a pointer which points to commit id in git. making HEAD to move to different location is considered as checkout

  • Lets create branches for apple, core and amazon Preview

  • Moving around branches Preview Preview

  • If you want create a branch and move the HEAD to that branch (Our sales struck a new deal of tesla, so we need to create)

git checkout master
git checkout -b testla => create a new branch & checkout to that branch

Preview

How Git Works?

  • Git is a content tracker

  • Create a new directory and execute git init, a .git folder will be created. Preview

  • Lets add two simple files (Readme.md, .gitignore) Preview

  • Now execute git log Preview

  • Lets understand hashing: Hash algorithms are functions that generate a fixed length result (the hash) from a given input. Preview Preview

  • Git uses SHA-1 Hashing to generate commit ids

  • Git commit id is SHA-1 hash of

    • Snapshot of changes in staging area
    • Author name
    • Author email
    • Date time
    • Commit message
  • How git maintains versions

    • We have create changes in git which appear as Preview
    • Lets use plumbing commands
    git cat-file -t # This command will tell the type 
    git cat-file -p # This will print the contents of SHA1 hash
    
    • When we print commit id we get
      • tree => snapshot of changes done in staging area
      • parent => parent commit id
      • author =>
      • committer =>
      • commit message Preview
    • Now lets explore the snapshot Preview
    • blob stands for file and the hash is hash of contents in the file and tree is folder. Preview
    • Now for the current commit the previous commit will be parent and git travels to the initial commit (commit with no parent) Preview
    • Now lets create a new commit by copying the same file in 3 different folders Preview Preview Preview
    • Now lets look into .git folder, The hashes are encoded in to .git/objects
    • Our current working tree depends on pointer HEAD Preview
    • Summarize:
      • HEAD points to Branch which in turns points to latest commit id
    • Git always recommends that HEAD should be pointing to branch not commit, when we force git to do this then it gets into detached head Preview Preview Preview
    • Internally Branch is nothing but a moving pointer which points to latest commit
  • Apple and Amazon have asked for features, There are some common features which

    • core team will work
    • Rest of features will be worked by customer teams
  • How can i make change in one branch and ensure that change is available to other branches

  • Next Steps:

    • Merge
    • Cherry pick
    • Rebase
    • Remotes
    • Tags
    • Un staging the changes
    • modifying commits
    • git sub modules & hooks ( After we finish jenkins concepts)
    • git branching strategy ( After we finish jenkins concepts)

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