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

Day 10 Task|: 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.

Default Branch name is Master.

Git Revert and Reset:

Two commonly used tools that git users will encounter are those of git reset and git revert . The benefit of both of these commands is that you can use them to remove or edit changes you’ve made in the code in previous commits.

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.

Git checkout

Git checkout is used to discard the changes in the working repository.

Git reset

git reset is used when we want to unstage a file and bring our changes back to the working directory. git reset can also be used to remove commits from the local repository.

Git revert

git revert is used to remove the commits from the remote repository. Since now our changes are in the working directory, let’s add those changes to the staging area and commit them.

Git merge:

The git merge command allows you to join two or more development work created using git branch into a single branch. It incorporates the changes from named commits and diverges them into the current branch. Before making merge option Make sure the receiving branch and the merging branch are up-to-date with the latest remote changes.

Git rebase:

Rebase is one of two Git utilities designed to integrate changes from one branch onto another. Rebasing is the process of combining or moving a sequence of commits on top of a new base commit. Git rebase is the linear process of merging.

Merge VS Rebase:

Merge

Rebase

Merge lets you merge different Git branches.

Rebase allows you to integrate the changes from one branch into another.

Merge logs show you the complete history of commit merging.

Rebase logs are linear. As the commits are rebased, the history is altered to reflect this.

All the commits on a feature branch are combined into a single commit on the master branch.

All commits are rebased, and the same number of commits are added to the master branch.

Merge is best used when the target branch is supposed to be shared.

Rebase is best used when the target branch is private.

Merge preserves history.

Rebase rewrites history.

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 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

Git merge :

Git Rebase:as a practice try git rebase too, see what difference you get.

Thank you for reading!! Hope you find this helpful.

#day10challenge#90daysofdevops

Always open for suggestions..!!

Thankyou Shubham Londhe !!