DevOps Classroomnotes 29/May/2022

Git Tags

  • Git has a concept called as tagging using git tag command.
  • Tags are ref’s that points to specific commit (points) in Git History
  • A tag is like a branch that doesn’t change
  • To create a tag git tag <tagname>
  • Git supports two types of tags
    • Annotated Tag:
      • This storage extra metadata such as tagger name, email and date.
      • command git tag -a <TagName> -m "<Tag Message>"
        Preview
        Preview
    • Lightweight Tag:
      • This is like a bookmark to a commit
      • command: git tag <TagName>
        Preview
        Preview
  • ReTagging:
    Preview
  • Best Practice is to use Annotated tags as public tag and lightweight tags for private
  • Tags is a standard practice to mark some thing important in Git History like
    • Given release to internal QA team
    • All the bugs fixed on a particular commit
    • Given release to external Team etc

Git Submodules

  • Lets assume you have different git repos for different apis build by your team
  • Lets clone a repo and add other repositories as submodules
    Preview
  • After pushing the changes and view them on github
    Preview
    Preview
  • Now lets work with submodules and make changes
    Preview
    Preview
    Preview
    Preview
    Preview
  • Clone the following git repo https://github.com/GitPracticeRepo/qtecommerceapr.git
git clone --recursive https://github.com/GitPracticeRepo/qtecommerceapr.git
or
git clone https://github.com/GitPracticeRepo/qtecommerceapr.git
cd qtecomerceapr
git submodule update --init
  • To pull all the repository changes including submodules
    Preview

Git Alias

  • Git alias is a shortcut to some git command
  • If i want a shortcut to status command as st
git config --global alias.st status
  • Alias are stored in <HOME-DIR>/.gitconfig
  • Create any two aliases and verify the config file and command usage
    Preview

Branching Strategies

  • We will discuss two branching strategies
    • Git Flow
    • GitHub Flow
    • GitLab Flow

Git Flow

GitHub Flow

Preview

GitLab Flow

Preview

Pull Request

  • A Pull request is also referred as merge request.
  • This happens when developer is ready to begin the process of merging the code changes to a branch or repository
  • As a Developer, We review the code on pull request.
  • As a DevOps Engineer, When Developer submits a pull request we run ci and quality gate & only if it works we allow the merge to happen
  • Lets see pull request in action. Refer Here
  • We can integrate pull request in

Git Hooks

  • Git Hooks are the scripts that Git Executes before or after events such as commit, push and recieve
  • There are two groups of hooks
    • Client Side Hooks/local hooks:
      • These execute on local repo
    • Server Side Hooks/Remote Hooks:
      • These execute on remote repo
  • Refer Here for the atlassian docs
  • Refer Here for the repository with useful hooks
  • Cloud providers give a workaround to run the server side hooks which are referred as webhooks

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner