Advance Git & GitHub for DevOps Engineers -Part:1

Advance Git & GitHub for DevOps Engineers -Part:1

#90Days DevOps Challenge Day-10

In this blog, we will study some of the advanced concepts of Git and GitHub. Stay with us until the end, and I'm sure you will learn a lot.

Git Branching:

When working with Git branching, you can make a copy of a file to work on without affecting the original copy. You have the option to merge these changes with the original copy or keep the branch separate. This allows you to experiment and make changes without worrying about damaging the original file.

Example: Think of Git branching like making a copy of a recipe before you start cooking. You can make changes to the copy without worrying about messing up the original recipe. If you like your changes, you can merge them with the original recipe. If not, you can throw away the copy and start over without affecting the original recipe.

What Is Git Rebase?

Git rebase is a command used to integrate changes from one branch into another. It works by moving the changes of one branch to the tip of another branch.

The advantage of using rebase over merge is that it creates a linear history of the changes, making it easier to understand the development of the project

Do check out more details below links.

https://www.youtube.com/watch?v=f1wnYdLEpgI

https://www.atlassian.com/git/tutorials/merging-vs-rebasing#the-golden-rule-of-rebasing

What Is Git Merge?

Git merge is like putting together pieces of a puzzle. When different people work on different parts of a project, they create separate puzzle pieces*(branchs)*. Git merge helps you combine those pieces into one complete puzzle. It's like taking the finished pieces from everyone and putting them together to make the whole picture.

Git Revert and Reset

Git revert allows you to undo a single commit by creating a new commit that undoes the changes made in the previous commit. It essentially creates a new commit that is the opposite of the previous one. This is useful if you want to undo a specific commit without affecting the other commits in the repository.

On the other hand, git reset allows you to undo changes to the repository by moving the branch pointer to a previous commit. This can be used to undo changes to multiple commits or even the entire repository. However, it should be used with caution as it permanently removes the undone commits from the repository's history.

In summary, git revert is a safer option when you want to undo a single commit, while git reset should be used carefully when undoing multiple commits or reverting the entire repository.

\>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Let's Jump for Tasks:

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 from master, [hint try git checkout -b dev], swithch to dev branch ( Make sure your commit message will reflect as "Added new feature"). [Hint use your knowledge of creating branches and Git commit command]

  • version01.txt should reflect at local repo first followed by Remote repo for review. [Hint use your knowledge of Git push and git pull commands here]

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 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 with screenshot.

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

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

    After rebasing

    ****************************************************************************

    Thank you for reading my blog on Advance Git & GitHub for DevOps Engineers - Part 1. I hope you found it informative and useful in your work with Git and GitHub