Day 13 Task: Advance Git & GitHub for DevOps Engineers

Hi, I’m Rakshita. A Cloud, DevOps, AI, and Python enthusiast passionate about learning and simplifying technology for others. I love exploring how modern tools and automation can make systems smarter and more efficient. Here, I write about: ☁️ Cloud & DevOps practices 🤖 AI in the world of automation 🐍 Python for real-world problem-solving 💡 Growth, consistency, and the learner’s mindset My goal is to bridge the gap between learning and doing, and help others grow confidently in the evolving tech landscape.
Git Branching
In Git, a branch is a new/separate version of a main repository. Git branch are pointer to a snapshot of your changes. The master branch is a default branch in Git./
When you want to add a new feature or fix a bug, no matter how big or small it is, you create a new branch to make your changes. If the changes in new branch are well suited and tested, the new branch will be merged to master branch and applied in production.

Git Revert and Reset
Git Revert command helps you undo an existing commit. It does not delete any data in the process, rather it creates a new commit with the included files reverted to their previous state. So, your version control history moves forward while the state of your file moves backward.
Git Reset is a powerful command that is used to undo local chnages to the state of a git repository. It is generally used at the time of merge conflicts to reset the conflicted files to their original state.
These forms correspond to command line arguments --soft, --mixed, --hard.
--soft: Aims to change the HEAD (where the last commit is in your local machine) reference to a specific commit. For instance, if we realize that we forgot to add a file to the commit, we can move back using the --soft
--mixed: Any changes that have been undone from the Staging Index are moved to the Working Directory.
--hard: All the pending work in Staging area and Working Directory willbe lost.
Git Rebase and Merge
Git Rebase: Rebasing is the process of moving or combining a sequence of commits to a new base commit. Rebasing is most useful and easily visualised in the context of a feature branching workflow. The primary reason for rebasing is to maintain a linear project history.

Git Merge: It is used to combine the changes from one or more branches into the current branch. Git merge will associate a series of commits into one unified history. Generally, git merge is used to combine two branches.

Tasks
Task 1: Feature Development with Branches
Create a Branch and Add a Feature:
Add a text file called
version01.txtinside theDevops/Git/directory with “This is the first feature of our application” written inside.mkdir -p Devops/Git && cd Devops/Git && touch version01.txtvim version01.txt
Create a new branch from
master.git checkout -b dev
Commit your changes with a message reflecting the added feature.
git add Devops/Git/version01.txt git commit -m "Added new feature"
Push Changes to GitHub:
Push your local commits to the repository on GitHub.
git push origin dev

Add More Features with Separate Commits:
Update
version01.txtwith the following lines, committing after each change:1st line:
This is the bug fix in development branchecho "This is the bug fix in development branch" >> version01.txt git commit -am "Added feature2 in development branch"
2nd line:
This is gadbad codeecho "This is gadbad code" >> version01.txt git commit -am "Added feature3 in development branch"
3rd line:
This feature will gadbad everything from nowecho "This feature will gadbad everything from now" >> version01.txt git commit -am "Added feature4 in development branch"
Restore the File to a Previous Version:
Revert or reset the file to where the content should be “This is the bug fix in development branch”.
git revert HEAD~2
Task 2: Working with Branches
Demonstrate Branches:
Create 2 or more branches and take screenshots to show the branch structure.

Merge Changes into Master:
Make some changes to the
devbranch and merge it intomaster.git checkout master git merge dev
Practice Rebase:
Try rebasing and observe the differences.
git rebase master
HAPPY LEARNING🌟



