Day 11 Task: Advance Git & GitHub for DevOps Engineers: Part-2

Day 11 Task: Advance Git & GitHub for DevOps Engineers: Part-2

Git Stash:

Git stash is a command that allows you to temporarily save changes you have made in your working directory, without committing them. This is useful when you need to switch to a different branch to work on something else, but you don't want to commit the changes you've made in your current branch yet.

To use Git stash, you first create a new branch and make some changes to it. Then you can use the command git stash to save those changes. This will remove the changes from your working directory and record them in a new stash. You can apply these changes later. git stash list command shows the list of stashed changes.

You can also use git stash drop to delete a stash and git stash clear to delete all the stashes.

Cherry-pick:

Git cherry-pick is a command that allows you to select specific commits from one branch and apply them to another. This can be useful when you want to selectively apply changes that were made in one branch to another.

To use git cherry-pick, you first create two new branches and make some commits to them. Then you use git cherry-pick <commit_hash> command to select the specific commits from one branch and apply them to the other.

Resolving Conflicts:

Conflicts can occur when you merge or rebase branches that have diverged, and you need to manually resolve the conflicts before git can proceed with the merge/rebase. git status command shows the files that have conflicts, git diff command shows the difference between the conflicting versions and git add command is used to add the resolved files.

Task-01

Create a new branch and make some changes to it.

Use git stash to save the changes without committing them.

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

Switch to a different branch, make some changes and commit them.

No alt text provided for this image

Use git stash pop to bring the changes back and apply them on top of the new commits.

No alt text provided for this image

Task-02

In version01.txt of development branch add below lines after “This is the bug fix in development branch” that you added in Day10 and reverted to this commit.

Line2>> After bug fixing, this is the new feature with minor alteration”

Commit this with message “ Added feature2.1 in development branch”

No alt text provided for this image

Line3>> This is the advancement of previous feature

Commit this with message “ Added feature2.2 in development branch”

No alt text provided for this image

Line4>> Feature 2 is completed and ready for release

Commit this with message “ Feature2 completed”

No alt text provided for this image

All these commits messages should be reflected in Production branch too which will come out from Master branch (Hint: try rebase).

No alt text provided for this image

I have switched from dev to production and used git rebase command ,now all the commits are merged in production.

No alt text provided for this image

Task-03

In Production branch Cherry pick Commit “Added feature2.2 in development branch” and added below lines in it:

  1. Switch to production branch.
  2. for cherry-pick use command:?git cherry-pick <commit ID for feature2.2>
  3. here cherry-pick gives conflict error. so we need to solve conflict error

No alt text provided for this image

4. After resolving conflict error use command git cherry-pick <commit ID> or git cherry-pick --continue

5. In git log, you can check commit is at the top.

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

Line to be added after Line3>> This is the advancement of previous feature

Line4>>Added few more changes to make it more optimized.

Commit: Optimized the feature

No alt text provided for this image

Thank you for reading this Article.

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

Deepika D的更多文章

  • Day 28 Task: Jenkins Agents

    Day 28 Task: Jenkins Agents

    Jenkins Master (Server) Jenkins’s server or master node holds all key configurations. Jenkins master server is like a…

    4 条评论
  • Day 27 Task: Jenkins Declarative Pipeline with Docker

    Day 27 Task: Jenkins Declarative Pipeline with Docker

    Use your Docker Build and Run Knowledge docker build - you can use sh docker build . -t in your pipeline stage block…

    1 条评论
  • Day 26 Task: Jenkins Declarative Pipeline

    Day 26 Task: Jenkins Declarative Pipeline

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

  • Day 24 Task: Complete Jenkins CI/CD Project

    Day 24 Task: 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 connection to…

  • Day 23 Task: Jenkins Freestyle Project for DevOps Engineers.

    Day 23 Task: 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…

  • Day-22 : Getting Started with Jenkins

    Day-22 : Getting Started with Jenkins

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

  • Day 21 Task: Docker Important interview Questions.

    Day 21 Task: Docker Important interview Questions.

    Docker Interview Docker is a good topic to ask in DevOps Engineer Interviews, mostly for freshers. One must surely try…

    6 条评论
  • Day 20 Task : Docker commands Cheat-Sheet

    Day 20 Task : Docker commands Cheat-Sheet

    Docker commands: # docker build: Builds an image from a Dockerfile. docker build [OPTIONS] PATH | URL | docker build…

  • Day 19 Task: Docker for DevOps Engineers

    Day 19 Task: Docker for DevOps Engineers

    Docker-Volume Docker allows you to create something called volumes. Volumes are like separate storage areas that can be…

    3 条评论
  • Day 18 Task: Docker for DevOps Engineers

    Day 18 Task: Docker for DevOps Engineers

    Docker Compose Docker Compose is a tool that was developed to help define and share multi-container applications. With…

社区洞察