Table of contents
- Git Revert and Reset
- Git Rebase and Merge
- What Is Git Rebase?
- What Is Git Merge?
- Task 1: Add a text file called version01.txt inside the Devops/Git/ with “This is the first feature of our application” written inside.
- version01.txt should reflect at the local repo first followed by the Remote repo for review.
- Task 2: Add a 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
- Task 3: Demonstrate the concept of branches with 2 or more branches with a screenshot.
- Task 4: Add some changes to dev branch and merge that branch in master.
#90daysDevOpsChallenge
#day10
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 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.
Task 1: Add a text file called version01.txt inside the Devops/Git/ with “This is the first feature of our application” written inside.
version01.txt should reflect at the local repo first followed by the Remote repo for review.
Task 2: Add a 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 the development branch
Commit this with the 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 3: Demonstrate the concept of branches with 2 or more branches with a screenshot.
By using "Master" branch, I have created two branches "Main" and "Dev".
"Master" branch has stable code.
Let's take an example.
You want to make some changes in your code. in that case, you can't edit your master branch code, otherwise, you lose your stable code. so the solution is that you need to create a feature branch from the master branch and then make your changes.
sometimes have different changes like some related to development and some related to others so use different branches and commit changes. At the end merge all the branches.
Task 4: Add some changes to dev
branch and merge that branch in master.
Before using rebase, only add a new file "version02.txt" in the "dev" branch.
After performing git rebase, merge "dev" branch to "master" branch.
Note: If you are facing any problems pushing your code into the repository you can check on my previous blog Git & GitHub Basic, already explained in detail.
The Next Article will discuss Advanced Concepts of Git & Github - PART2 ...
Thank you for giving your precious time to read this blog/article and if any suggestions or improvements are required on my blogs feel free to connect on Linkedin Unnati Gupta.