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

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

ยท

2 min read

Welcome back to the second part of our series on Advance Git & GitHub for DevOps Engineers! In this installment, we'll delve deeper into some advanced Git techniques that will streamline your workflow and enhance collaboration within your development team. Let's dive right in!

Task-01: Branching and Stashing

One of the fundamental aspects of Git is its powerful branching model, allowing developers to work on multiple features simultaneously without interfering with each other's work. In this task, we'll demonstrate how to create a new branch, make changes, stash them, switch to another branch, and apply the stashed changes.

  1. Create a new branch and make changes:

  2. Use git stash to save the changes without committing them:

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

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

Task-02: Working with Branches and Commits

In this task, we'll manipulate commits across branches, specifically focusing on versioning and feature additions.

  1. Switch to the development branch:

  2. Edit version01.txt and add the specified lines:

  3. Commit with message "Added feature2.1 in development branch":

  4. Add more lines to version01.txt:

  5. Commit with message "Added feature2.2 in development branch":

  6. Add final lines and commit:

  7. Switch to the master branch:

  8. Merge development into master:

  9. Rebase production branch on master:

    Now, the commits and messages from the development (dev) branch will be reflected in the production branch.

Task-03: Cherry Picking and Optimizing Features

Cherry-picking allows us to select specific commits from one branch and apply them onto another. In this task, we'll cherry-pick a commit from the development branch into the production branch and optimize it.

  1. Cherry-pick commit "Added feature2.2 in development branch" into production branch:

     git checkout production
     git cherry-pick 6ca679d
    

  2. Edit version01.txt and add the specified lines:

  3. Commit the changes with the message "Optimized the feature":

By following these steps, you can effectively manage your Git workflow and ensure that your codebase remains organized and efficient. Stay tuned for more advanced Git techniques in the next part of our series!

That wraps up our discussion on Advance Git & GitHub for DevOps Engineers: Part-2. We hope you found these techniques useful and applicable to your projects. Happy coding!

I'm confident that this article will prove to be valuable, helping you discover new insights and learn something enriching .

thank you : )

ย