Day 10 :Advance Git & GitHub for DevOps Engineers.

• Git Branching :

A branch is a version of the repository that diverges from the main working project. It is a feature available in most modern version control systems. A Git project can have more than one branch. These branches are a pointer to a snapshot of your changes. When you want to add a new feature or fix a bug, you spawn a new branch to summarize your changes. So, it is complex to merge the unstable code with the main code base and also facilitates you to clean up your future history before merging with the main branch.

• Git Revert and Reset:

* Git Revert:- git revert creates a new commit with the previous commit that you are reverting back to. Instead of destroying everything back to that commit, you simply make a copy of that and move forward with that commit. No commits are destroyed in the process. Imagine if you wanted to go back 30 commits. If you used git reset all 29 of those commits would be deleted. git revert allows you to save all that history and creates a safe way to proceed forward.

* Git Reset:- git reset HEAD allows you to go back to a previous commit and removes any other commits on its way back. Imagine someone mopping a floor. If someone wants to clean up a hallway, they don’t just clean the end. They mop all of the floor all they way back to the end of the hallway. This type of undoing a mistake ensures you clean up everything on the way back to the commit you want to go back to. On the other hand, this is a destructive option and it doesn’t save any history of what you deleted.

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

Task 1:

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” [Hint use git revert or reset according to your knowledge]

Once commits are performed you can check log history with command

git log

After using git log you able to see the details : Unique commit id , Author details(Name & Email id ) ,Date & Commit message

Later run the command : git reset <Commit id>

After using rest command if you check the log History again you will see only one commit as other commits deleted.

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.

git-rebase command is used to reapply commits on top of another base tip

Thank you for Reading..!

"Embark on the Journey of Knowledge: Happy Learning Lights Up Your Path."

_Abhi Sagare.