π― What is Branching in DevOps?
- The branching is a separate line of development from the main code, which allows developers to track and make changes to their code over time without affecting the main line of code.
Source: https://www.sitepoint.com
π― What is Git Revert & Git Reset?
Source: https://ln.ki/KodeKloud-IG
Git Revert: Git Revert generates a new commit that undoes the changes made in a previous commit.
Git Reset: Git Reset discards all commits after a specified commit.
π― What is Git Rebase & Git Merge?
Source: https://ln.ki/KodeKloud-IG
Git Rebase: Git Rebase updates the current branch with changes from another branch.
Git Merge: Git Merging is the process of combining two branches into one.
Exercises:
πTask 1: Exploring the Revert and Reset concept in Git
πΎStep 1: Add a text file called version01.txt inside Devops/Git/ with "This is first feature of our application" written inside and coming from the Master branch.
πΎStep 2: version01.txt should reflect at the local repo first followed by the remote repo.
πΎStep 3: Add a new commit in dev
the branch after adding the 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 the message β Added feature2 in development branchβ
2nd line>> This is gadbad code
Commit this with the message β Added feature3 in development branch
3rd line>> This feature will gadbad everything from now.
Commit with the message β Added feature4 in development branch
πΎStep 4: Restore the file to a previous version where the content should be βThis is the bug fix in development branchβ.
# Syntax
git reset --hard <commit_hash>
# Example
git reset --hard 2e5b93b
πTask 2: Understanding the Concepts of Rebasing and Merging in Git
Source: https://www.simplilearn.com
πΎStep 1:
(Case 1): Merge feat-1.txt and feat-2.txt files from the Stage branch into the Main branch.
# Syntax
git merge <branch_name>
# Example
git merge stage
(Case 2): Merge the feat-4.txt file from the Stage branch into the Main branch.
# Syntax
git merge <branch_name>
# Example
git merge stage
Note: In case 2, when merging from the Stage branch to the Main branch, both HEADs are not aligned on the same line as observed in case 1. Hence, it's not necessary to emphasize being on the same branch.
πΎStep 2: Rebase the Main and Stage branch in the same line.
# Syntax
git rebase <branch_name>
# Example
git rebase main
Note: When you observe a rebase conducted from the staging branch to the main branch, both HEADs synchronize on the same line. Rebase brings the main and staging branches into one history, unlike merge, which doesn't follow this linear synchronization history.
Happy coding! ππΎ
β Feel free to reach out if you have any questions. I'm delighted to help! π
π€ Let's Connect..!
π LinkedIn
π Twitter
π GitHub
βοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈβοΈ