#Day 10 - Advance Git & GitHub

Passionate AWS Developer | DevOps Engineer with a strong background in cloud architecture and solutions engineering. Leveraging the power of Amazon Web Services (AWS), knowledge of the AWS global infrastructure, design and implement robust cloud-based solutions that align with clients' specific needs.
Git Branching:
Git branches are effectively a pointer to a snapshot of your changes. When you want to add a new feature or fix a bug—no matter how big or how small—you spawn a new branch to encapsulate your changes.
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 git reset:
git revert is a Git command used to create a new commit that undoes the changes made in a previous commit. It allows you to effectively remove or reverse the effects of a particular commit, making it a valuable tool for managing the version history of a Git repository while preserving the historical record of changes.
Git reset is a powerful command that undoes changes, moving the repository back to a previous commit, and eliminating any changes made after the commit. It’s literally hitting the “reset” button, undoing local changes.
Git rebase and git merge:
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.
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 01:
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.
In this task, we’ll explore how to create a new branch, make changes with various messages, and restore a file to an earlier version.
The steps are as follows:



Connect your local repo to remote github

Make additional commits to the dev branch by updating the version01.txt file and commit this change with the message “Making the following changes: …”.

Perform this step two additional times, including the provided content, and commit each change with relevant messages.

Again for adding feature4

adding feature 5

Revert the version01.txt file to a previous state with the content “This is the bug fix in the development branch.”
Using the “git log — oneline” command, find the <commit> information and identify the commit you want to reset to.

Task 2:
Branching, Merging, and Rebasing
In this task, we will explore the concepts of branches, merging, and rebasing. To get started, follow these steps:
Let’s merge the “dev” branch with the “main” branch. First, check the commits on the “dev” branch by using “git checkout dev”. Then, switch back to the “main” branch and check its commits as well. Now, execute the “git merge dev” command to combine the commits and observe the results.

As a practice, perform a
git rebaseoperation to see the difference it makes. Describe the differences you observe
In this sequence of commands, developers start by checking out the “dev” branch in Git. They then create a new text file called “version01.txt” with specific content. The changes to this file are staged and committed with an appropriate commit message. After inspecting the commit history on the “dev” branch, they switch to the “main” branch and perform a rebase.
During the rebase, the commits from the “dev” branch are moved on top of the existing commits in the “main” branch, resulting in an updated, linear commit history on the “main” branch. This process demonstrates how branches interact, and how Git’s merge and rebase commands can be used to manage code development seamlessly.
Note: Git merge combines changes and preserves the original commit history, while Git rebase moves commits to create a cleaner, linear commit-graph, making project tracking easier.



