Advance Git & GitHub for DevOps Engineers :

Advance Git & GitHub for DevOps Engineers :

Git Branching :

In Git, a branch is a separate line of development that allows multiple contributors to work on different features or bug fixes simultaneously without interfering with each other's work. Branches are an integral part of the Git workflow, and they make it easy to switch between different versions of your code, manage merge conflicts, and collaborate with others on a project. You can create a new branch, switch between existing branches, and merge branches together to bring changes from one branch into another. The main branch in Git is typically called "master."

Git Revert and Reset :

In Git, the revert command is used to undo the changes made in a specific commit. When you revert a commit, Git creates a new commit that undoes the changes made in the original commit. The original commit is not deleted, but its changes are undone in a new commit.

The reset command, on the other hand, discards commits, moving the branch pointer to a previous commit and destroying the commits in the branch that come after it. This is a more destructive operation, as it permanently removes commits from the branch's history.

Git Rebase and Merge :

  • What Is Git Rebase : Git rebase is a command that lets users integrate changes from one branch to another, and the logs are modified once the action is complete. Git rebase was developed to overcome merging’s shortcomings, specifically regarding logs.
  • What Is Git Merge : Git merge is a command that allows developers to merge Git branches while the logs of commits on branches remain intact. The merge wording can be confusing because we have two methods of merging branches, and one of those ways is actually called “merge,” even though both procedures do essentially the same thing.

Task 1 :

Add a text file called version01.txt inside the Devops/Git/ with “This is first feature of our application” written inside. This should be in a branch coming from?master, [hint try?git checkout -b dev], swithch to?dev?branch ( Make sure your commit message will reflect as "Added new feature"). [Hint use your knowledge of creating branches and Git commit command]

No alt text provided for this image
No alt text provided for this image

  • version01.txt should reflect at local repo first followed by Remote repo for review. [Hint use your knowledge of Git push and git pull commands here]

No alt text provided for this image
No alt text provided for this image

Add new commit in?dev?branch after adding below mentioned content in Devops/Git/version01.txt: While writing the file make sure you write these lines,

  • 1st line>> This is the bug fix in development branch.
  • Commit this with message “ Added feature2 in development branch"

No alt text provided for this image

  • 2nd line>> This is gadbad code
  • Commit this with message “ Added feature3 in development branch

No alt text provided for this image

  • 3rd line>> This feature will gadbad everything from now.
  • Commit with message “ Added feature4 in development branch

No alt text provided for this image

Restore the file to a previous version where the content should be “This is the bug fix in development branch” [Hint use git revert or reset according to your knowledge]

No alt text provided for this image

Task 2 :

  • Demonstrate the concept of branches with 2 or more branches with screenshot.

When you create a new project in Git, it creates a default branch called "master." The master branch is the main branch of the repository, and it is where all development begins. As you make changes to the project, you can create new branches to test different ideas or to work on different features.

For example, you might create a branch called "feature1" to work on a new feature for your project. You can continue to make changes to this branch, and when the feature is complete, you can merge it back into the master branch.

  • Add some changes to?dev?branch and merge that branch in?master.

No alt text provided for this image

  • As a practice try git rebase too, see what difference you get.

In Git, "rebase" is an operation that allows you to integrate changes from one branch into another branch. It works by taking the commits from one branch and "replaying" them on top of the other branch.

When you use "git rebase," it effectively replaces the existing commits in the target branch with new ones that include the changes from the source branch. This can be useful in situations where you want to keep the commit history of your branch clean and linear, rather than having multiple merge commits.


Thank you for reading! I hope you find this article helpful.

Happy Learning :)

要查看或添加评论,请登录

Nihal Apretwar的更多文章

  • SQS (Simple Queue Service):

    SQS (Simple Queue Service):

    What is SQS: Amazon Simple Queue Service (SQS) is a managed message queuing service technical professionals and…

  • Amazon S3: (Simple Storage service):

    Amazon S3: (Simple Storage service):

    What is S3: It provides object storage which is build for storing and recovering any amount of data from anywhere over…

  • Elastic Compute Cloud (EC2)

    Elastic Compute Cloud (EC2)

    What is EC2 : Amazon EC2 Provides secure and resizable compute capacity in the AWS cloud. You can use Amazon EC2 to…

  • IAM (Identity and Access Management)

    IAM (Identity and Access Management)

    IAM : AWS identity access management is a web service that help you securely control access to AWS resources. You use…

  • AWS (Amazon Web Services)

    AWS (Amazon Web Services)

    What is AWS ? AWS stands for Amazon web services. AWS is a secure cloud service platform that provides on-demand…

    1 条评论
  • Jenkins Declarative Pipeline:

    Jenkins Declarative Pipeline:

    One of the most important parts of your DevOps and CICD journey is a Declarative Pipeline Syntax of Jenkins. Some…

  • Complete Jenkins CI/CD Project - Continued with Documentation

    Complete Jenkins CI/CD Project - Continued with Documentation

    I can imagine catching up will be tough so take a small breather today and complete the Jenkins CI/CD project from Day…

    6 条评论
  • Complete Jenkins CI/CD Project:

    Complete Jenkins CI/CD Project:

    Let's make a beautiful CI/CD Pipeline for your Node JS Application ?? Task-01: Fork this repository: Create a…

    1 条评论
  • Jenkins Freestyle Project for DevOps Engineers:

    Jenkins Freestyle Project for DevOps Engineers:

    What is CI/CD? CI or Continuous Integration is the practice of automating the integration of code changes from multiple…

  • Getting Started with Jenkins:

    Getting Started with Jenkins:

    What is Jenkins? Jenkins is an open source continuous integration-continuous delivery and deployment (CI/CD) automation…

    2 条评论

社区洞察

其他会员也浏览了