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

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

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


Git Branching

Use a branch to isolate development work without affecting other branches in the repository. Each repository has one default branch, and can have multiple other branches. You can merge a branch into another branch using a pull request.

Branches allow you to develop features, fix bugs, or safely experiment with new ideas in a contained area of your repository.


Git Revert and Reset

Two commonly used tools that git users will encounter are 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.

Refer to this article for a better understanding of Git Rebase and Merge?Read here


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]


No alt text provided for this image
No alt text provided for this image


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

No alt text provided for this image


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”

No alt text provided for this image


  • 2nd line>> This is gadbad code
  • Commit this with message “ Added feature3 in development branch

No alt text provided for this image


  • 3rd line>> This feature will gadbad everything from now.
  • Commit with the message “ Added feature4 in development branch

No alt text provided for this image
No alt text provided for this image


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]

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image



Task 2:

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

Command to know the current branch

No alt text provided for this image

Checkout to main branch

No alt text provided for this image

Checkout to dev branch

No alt text provided for this image


  • add some changes to?the dev?branch and merge that branch into?master


No alt text provided for this image


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

Log of Main branch

No alt text provided for this image


Checkout feature00 branch from log 976e7f5 of the main branch and created file feature01.txt and commit.

No alt text provided for this image


Log of feature00 branch

No alt text provided for this image


Rebase the main branch in the feature00 branch and see the log, feature01.txt has been added to the main branch

No alt text provided for this image


Rebase feature00 in the main branch by switching to the main branch and see logs that commits of the feature00 branch have been added to the main branch

No alt text provided for this image

#github #git #gitmerge #gitrebase #devops #linux #aws #90daysofdevops

Git offers two powerful techniques - merging and rebasing. Discover the differences, advantages, and best practices of each technique to make informed decisions for your projects. bit.ly/3XRWRF3

回复

要查看或添加评论,请登录

Manish Negi的更多文章

社区洞察

其他会员也浏览了