Advance Git & GitHub for DevOps Engineers (day-10-task)

Advance Git & GitHub for DevOps Engineers (day-10-task)

1.Git Branching

Git branching is a powerful feature that enables developers to work on isolated instances of source code in parallel. It allows teams to experiment with changes and new features without affecting the main codebase, reducing risk and improving collaboration.

2.Git Revert and Reset

Use of Git Reset, Git Revert, Git Checkout & Squash Commit | by Amit  Prajapati | MindOrks | Medium

  • Git Revert creates a new commit that undoes the changes made in a previous commit. Using Git Revert keeps the commit history of the repository intact. Developers can use Git Revert to undo specific changes without affecting the rest of the commit history.

  • Git Reset is used to remove or reset changes from a Git repository, rewinding the repository back to a previous commit. Git Reset is useful when developers want to completely remove a commit or delete local changes yet to be committed. Developers can choose the type of reset—hard, mixed, or soft—to remove different levels of changes and files from the repository.

3.Git Rebase and Merge

An introduction to Git merge and rebase: what they are, and how to use them

  • Git Merge is used to combine changes from one branch into another. It creates a new commit that includes the changes from two branches, preserving the entire commit history of both branches. Git Merge is an easy-to-use feature for integrating changes quickly into a branch.

  • Git Rebase, on the other hand, allows developers to integrate changes from one branch into another but with a different approach. Instead of creating a new commit, Git Rebase moves all the changes from one branch to the beginning of another branch and replays them. This results in a streamlined commit history, with a clear linear relationship between commits. This linear history makes it easier to understand the changes that were made and when.

  • While the choice between Git Rebase and Merge depends on a developer's specific needs and preferences, Git Rebase is best used for keeping a linear and clean commit history, while Git Merge is better suited for incorporating changes into a branch and keeping a more extensive commit history.

Task 1:

1.Creating and modifying a feature branch in Git

  • Open terminal and navigate to the Devops/Git directory.

  • Create a new branch called 'dev' using the command

    git checkout -b dev.

  • Create a new text file called 'version01.txt' using a text editor and write "This is first feature of our application" inside the file.

  • Add the file to the staging area using the command git add version01.txt.

    &

  • Commit the changes to the branch with the command

    git commit -m "Added new feature".

  • Push the changes to the remote repository using the command

    git push origin dev

    .

  • Add a new line to the file with the text "This is the bug fix in development branch"

  • Add the file to the staging area using the command

    git add version01.txt.

  • Commit the changes with the message "Added feature2 in development branch" using the command

    git commit -m "Added feature2 in development branch".

  • Add another line to the file, this time with the text "This is gadbad code".

  • Add the file to the staging area using the command

    git add version01.txt.

  • Commit the changes with the message "Added feature3 in development branch" using the command

    git commit -m "Added feature3 in development branch".

  • Add a third line to the file with the text "This feature will gadbad everything from now."

  • Add the file to the staging area using the command

    git add version01.txt.

  • Commit the changes with the message "Added feature4 in development branch" using the command

    git commit -m "Added feature4 in development branch".

  • Push the changes to the remote repository using the command

    it push origin dev.

    Task 2:

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

    In Git, branches are essentially different versions of a codebase that allow multiple developers to work on the same project simultaneously without affecting the main codebase. Branches allow developers to experiment, add new features, or fix bugs without interfering with the work others are doing.

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

Thank you,