Day 10: Advance Git & GitHub for DevOps Engineers.

Day 10: Advance Git & GitHub for DevOps Engineers.

Git Branching

Git branching is a fundamental concept in version control systems, and it allows developers to work on different parts of a project separately. Each branch has its commit history, enabling developers to switch between branches and merge changes when necessary.

Git Revert and Reset

Git Revert and Reset are essential tools in Git that help you manage changes and undo mistakes. Use git revert when you want to undo specific changes with a new commit while preserving the original history. Use git reset when you need to go back to a specific point in history and remove commits from the branch.

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 called “merge,” even though both procedures do essentially the same thing.

Task 1: Demonstrate the concept of git revert or git reset depending on the use case.

Add a text file called version01.txt inside the Devops/Git/ with “This is the first feature of our application” written inside. This should be in a branch coming from the main, switch to dev branch ( Make sure your commit message will reflect as "Added new feature"). version01.txt should reflect at the local repo first followed by the remote repo for review.

  • Created and switched to a new branch "dev":

  • Created a new file:

  • Commit this change:

  • Push this change to the remote repository:

Add a new commit in dev branch after adding the 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 the development branch

    Commit this with the message “ Added feature2 in development branch”

  • 2nd line>> This is gadbad code

    Commit this with the message “ Added feature3 in the development branch

  • 3rd line>> This feature will gadbad everything from now.

    Commit with the message "Added feature4 in the development branch"

  • Check all the commit with git log:

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

Task 2: Demonstrate the concept of branches with 2 or more branches using git merge and rebase.

Add some changes to dev branch and merge that branch in main

After making the required changes in dev branch, checkout to the main branch before merging

Once the merge is successful, the changes made in the "dev" branch will be included in the "main" branch, and both branches will have the same content for the files that were modified.

I hope you like my blog..!!

Stay Connected with me for more interesting articles on DevOps, if you like my blog follow me on Hashnode and Linkedin (https://www.linkedin.com/in/som-shanker-pandey/)

Did you find this article valuable?

Support Som Pandey's blog by becoming a sponsor. Any amount is appreciated!