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

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

Git Branching:

Git branching is like creating parallel versions of a project to work on different tasks separately. It's like having multiple workspaces so changes in one don't affect the others. Once a task is complete, you can merge it back into the main project.

Git Revert and Reset:

Git Revert: creates a new commit that undoes changes from a previous commit, without erasing any history. It's like saying, "Oops, let's undo that last change, but show that we did it."

Git Reset: on the other hand, erases commits from the project history up to a specified point. It's like saying, "Let's pretend those changes never happened" and can be used to clean your project history or correct mistakes, but with caution since it can remove changes permanently.

Git Rebase and Merge

Git Rebase: Git rebase is like redoing your work on top of someone else's more recent work, making your project's history cleaner and more linear.

Git Merge: Git merge is like combining the contents of two notebooks into one, keeping the history of both visible.

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

version01.txt should reflect at local repo first followed by Remote repo for review.

swithch to dev branch,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”

    • 2nd line>> This is gadbad code

    • Commit this with message “ Added feature3 in development branch"

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

      • Commit with message “ Added feature4 in development branch

      • Restore the file to a previous version where the content should be “This is the bug fix in development branch”

    • Task 2:

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

    • Creating Branches in Git: If you don't have a Git repository yet, create one

    • Create a New Branch: To create a new branch, use the git branch command followed by the branch name:

    • Switch to the New Branch: To move to the newly created branch, use the git checkout command:

    • Make Changes in the Branch: Make some changes to your code or files while you're on dev branch

    • Add some changes todevbranch and merge that branch inmaster

    • Merge Branch: Finally, you can merge dev branch back into the main branch (master or main) using git merge:

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

  • Thank you for reading my blog. Don't forget to follow, comment and like my blog.

Did you find this article valuable?

Support Zehra Jabeen's Blog by becoming a sponsor. Any amount is appreciated!