Day 10 Task: Advance Git & GitHub for DevOps Engineers.
"Mastering Git and GitHub: Unleashing the Power of Advanced Version Control"
1. Branching in GitHub allows developers to diverge from the main line of
development, creating isolated paths for features, bug fixes, or releases.
Feature branches, bugfix branches, release branches, and hotfix branches help organize and parallelize development efforts.
After completing work in a branch, changes can be merged back into the main branch.
This approach enables collaborative development without disrupting the stability of the main codebase.
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 trygit checkout -b dev
], swithch todev
branch ( Make sure your commit message will reflect as "Added new feature").
- Here I have created the file version01.txt and added some content to it as you can see in the image .
- Here I have switched to dev branch and git add and commit the changes ,using git log we can view the commited changes in our local.
git push origin branch_name so that we can connect to github
- Here in github I have changed the branch to dev .
- Here we can see the file which was in our local .
From here git revert concept will start observe the images.
- First I have added the new lines in version01.txt and git add ,git commit .
-> "added more commands"
-> "added feature3 command"
-> "added feature4 command"
Here we can se all the commited changes by git log command.
Git Revert
Revert : Creates a new commit that undoes changes from a specified commit or range of commits. It's a safe way to undo changes without altering the commit history.
By using the below command we can revert the content in the file .
Before we can view all the content after using head command we can view only 2 lines as you can see in the image.
Git Merge
Merge : Combines changes with a new merge commit. Preserves branch histories. Good for collaboration.
Syntax : " git merge branch_name"
Here I have switched to dev and added some contents and commited the changes.
Here I have switched to master .
To get the file version01.txt from dev to master branch we have to merge , the command is git merge branch_name.
Here we can see the version01.txt which was in dev , now it is in master.
Git Rebase
Rebase : Transfers changes by reapplying commits onto another branch. Results in a cleaner, linear history.
Syntax : "git rebase branch_name"
Here I have created rebase.txt in dev branch and added some content in it and commited the changes.
Now we can view the file here.
Here I have switched to master branch
Before we cannot see the rebase.txt .
After giving the command git rebase branch_name we can see the rebase.txt
THANK YOU FOR READING!