Git Branching
Branching is a powerful feature of Git that enables teams to work simultaneously on multiple features or bug fixes without conflicts or interruptions. 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
Git revert and reset are two different commands in Git that are used to undo changes made to a repository. Git revert undoes a specific commit by creating a new commit that undoes the changes, while git reset removes one or more commits completely from the branch history.
What Is Git Rebase?
Git rebase is a command in Git that is used to change the base of a branch. It is a way of merging changes from one branch to another while maintaining a linear history. Unlike git merge, which creates a new commit to combine the changes from two branches, git rebase integrates the changes into the branch as if they were made directly on top of the current branch.
What Is Git Merge?
Git merge is a command in Git that is used to combine changes from one branch into another. The process of merging involves creating a new commit that combines the changes from two branches and updating the branch pointers to point to the new commit.
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
], switch to dev
branch ( Make sure your commit message will reflect as "Added new feature").
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”
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, and see what difference you get.
Thank you for reading!!
~Shreya Gupta
Great initiative by the #trainwithshubham community. Thank you Shubham Londhe
#devops #90daysofdevops #linux #git #github