Day 10 Task: Advance Git & GitHub for DevOps Engineers.

Day 10 Task: Advance Git & GitHub for DevOps Engineers.

Git Branching:

Use a branch to isolate development work without affecting other branches in the repository. Each repository has one default branch, and can have multiple other branches. You can merge a branch into another branch using a pull request.

Branches allow you to develop features, fix bugs, or safely experiment with new ideas in a contained area of your repository.

Git Revert and Reset

Two commonly used tools that git users will encounter are those of git reset and git revert . The benefit of both of these commands is that you can use them to remove or edit changes you’ve made in the code in previous commits.

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], switch 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
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

git log : Git log is?a utility tool to review and read a history of everything that happens to a repository.?

git log --oneline - The oneline option is used to display the output as one commit

per line.

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]

git reset : ?Reset current HEAD to the specified state.

syntax : git reset <commit_ID>

In below image, if you will do git log you can see only two commits as the reset ones are deleted.

No alt text provided for this image

Task 2:

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

git branch:

A branch is a version of the repository that diverges from the main working project. It is a feature available in most modern version control systems. A Git project can have more than one branch.

1.For show all branches:

git branch

2.Create a new branch:

git branch <branch_name>

3.For going to specific branch:

git checkout <branch_name>

4.For deleting branch:

git checkout -d <branch_name>

5. for creating and going to that branch:

git checkout -b <branch_name>

No alt text provided for this image

add some changes to?dev?branch and merge that branch in?master

No alt text provided for this image

git merge: Git merge is a command that allows developers to merge Git branches while the logs of commits on branches remain intact.

1.switch to master branch

2.git merge <branch_name> here branch_name is dev

3.check git log, In log head is master ,dev.

No alt text provided for this image

git rebase:

Rebasing is the process of moving or combining a sequence of commits to a new base commit. Rebasing is most useful and easily visualized in the context of a feature branching workflow. The primary reason for rebasing is to maintain a linear project history.

Syntax : git rebase <base>

  1. create a new branch
  2. create new file in that branch
  3. add and commit new file to that branch
  4. use command git rebase <branch_name>

No alt text provided for this image

Thank you for reading article!

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

Sayali Shewale的更多文章

  • DevOps Project-3

    DevOps Project-3

    Project Description The project involves hosting a static website using an AWS S3 bucket. Amazon S3 is an object…

    7 条评论
  • DevOps Project-2

    DevOps Project-2

    Project Description The project is about automating the deployment process of a web application using Jenkins and its…

    2 条评论
  • Day 80: DevOps Project-1

    Day 80: DevOps Project-1

    Project Description The project aims to automate the building, testing, and deployment process of a web application…

    4 条评论
  • Day 73 - Setup Grafana on AWS EC2 Instance

    Day 73 - Setup Grafana on AWS EC2 Instance

    Task: Setup grafana in your local environment on AWS EC2. Go to the AWS console and Launch an EC2 instance Open port…

    2 条评论
  • Day 72 - Grafana

    Day 72 - Grafana

    What is Grafana? Grafana is an open-source data visualization and monitoring tool that allows you to query, visualize…

    3 条评论
  • Day 70 - Terraform Modules

    Day 70 - Terraform Modules

    Modules are containers for multiple resources that are used together. A module consists of a collection of .

    2 条评论
  • Day 69 - Meta-Arguments in Terraform

    Day 69 - Meta-Arguments in Terraform

    When you define a resource block in Terraform, by default, this specifies one resource that will be created. To manage…

    1 条评论
  • Day 68 - Scaling with Terraform

    Day 68 - Scaling with Terraform

    Understanding Scaling Scaling is the process of adding or removing resources to match the changing demands of your…

  • Day 67: AWS S3 Bucket Creation and Management using terraform

    Day 67: AWS S3 Bucket Creation and Management using terraform

    AWS S3 Bucket Amazon S3 (Simple Storage Service) is an object storage service that offers industry-leading scalability,…

    1 条评论
  • Day 66 - Terraform Hands-on Project - Build Your Own AWS Infrastructure with Ease using Infrastructure as Code (IaC)

    Day 66 - Terraform Hands-on Project - Build Your Own AWS Infrastructure with Ease using Infrastructure as Code (IaC)

    Task: 1.Create a VPC (Virtual Private Cloud) with CIDR block 10.

    3 条评论

社区洞察

其他会员也浏览了