Skip to main content

Day 10 Task: Advance Git & GitHub for DevOps Engineers.

Updated 3 min readMarkdown

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 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.

Task 1:

Add a text file called version01.txt inside the Devops/Git/ with “This is the first feature of our application” written inside. This should be in a branch coming from master, [hint try git checkout -b dev], switch 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 the local repo first followed by the Remote repo for review. [Hint use your knowledge of Git push and git pull commands here]

Add a new commit in dev branch after adding the below-mentioned content in Devops/Git/version01.txt: While writing the file make sure you write these lines

Now,

first, you need to make the file:

now, check out the dev

git add the file and check the status.

git commit it and check the status

You can see that dev has been pushed:

  • 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 the message “ Added feature3 in the development branch

    • 3rd line>> This feature will gadbad everything from now.

    • Commit with the message “ Added feature4 in the development branch

Task 2:

Branching is one of the important topics in git first we will few branching commands:

1.For show all branches:

git branch

2.Create a new branch:

git branch <branch_name>

3. Create a branch without committing

git checkout -b <branchname>

3.For going to specific branch:

git checkout <branch_name>

4.For deleting branch:

git checkout -d <branch_name\>

5. for creating and going to that branch:

git checkout -b <branch_name>

  • Demonstrate the concept of branches with 2 or more branches with a screenshot.

  • Here we are adding the two branches first_branch and the second_branch.

    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 called “merge,” even though both procedures do essentially the same thing.

    Refer to this article for a better understanding of Git Rebase and Merge Read here

  • Add some changes to dev branch and merge that branch in master

    - First, you need to make the file, then add the file and commit the file

    - Then use the merge master and get the graph of the merge.

  • as a practice try git rebase too, and see what difference you get.

    Thanks for reading,

    Regards,

    Mohammed Muqafamuddin

No comments yet. Be the first to comment.

More from this blog