Day 10: Mastering Advanced Git & GitHub for DevOps Brilliance

Day 10: Mastering Advanced Git & GitHub for DevOps Brilliance

Git Branching: The Art of Isolation and Collaboration

Understanding Git Branches

In the world of Git, branches serve as parallel timelines within your repository, allowing you to compartmentalize development work. This functionality proves invaluable when working on features, fixing bugs, or experimenting with new ideas, all while safeguarding the stability of the main codebase.

Theoretical Insights: Branches offer a powerful mechanism to:

  1. Isolate Development Work:

    • Developers can create branches to work on specific features or bug fixes without disrupting the main code.
  2. Experiment Safely:

    • Branches provide a controlled environment to experiment with new ideas before integrating them into the primary codebase.
  3. Facilitate Collaboration:

    • Collaboration is streamlined through branches, allowing multiple developers to work on different features simultaneously.

Practical Task:

  1. Create a Dev Branch and Add Feature1:

     git checkout -b dev
     echo "This is the first feature of our application" > Devops/Git/version01.txt
     git add .
     git commit -m "Added new feature"
     git push origin dev
    
  2. Add New Commits in Dev Branch:

     echo "This is the bug fix in development branch" >> Devops/Git/version01.txt
     git add .
     git commit -m "Added feature2 in development branch"
    
     echo "This is gadbad code" >> Devops/Git/version01.txt
     git add .
     git commit -m "Added feature3 in development branch"
    
     echo "This feature will gadbad everything from now." >> Devops/Git/version01.txt
     git add .
     git commit -m "Added feature4 in development branch"
     git push origin dev
    
  3. Restore to Previous Version:

     git reset --hard <commit_hash_of_previous_version>
    

Navigating Git Tools: Revert and Reset

Git Revert and Reset: Rewriting Git History

In the Git universe, two crucial tools for rewriting history are git revert and git reset. Each serves a distinct purpose, offering developers flexibility in managing changes made in previous commits.

Theoretical Insights:

  1. Git Revert:

    • Enables developers to undo changes from previous commits while preserving a record of the reversion.

    • Ideal for maintaining a clear and transparent commit history.

  2. Git Reset:

    • Resets the current branch to a specific commit, erasing subsequent commits.

    • Useful when developers need to discard changes and start anew.

Practical Task:

  1. Demonstrate Git Reset:

     git reset --hard <commit_hash_to_reset_to>
    
  2. Demonstrate Git Revert:

     git revert <commit_hash_to_revert>
    

Stay tuned for the continuation of advanced Git concepts in the next section.

Continue reading on Hashnode.

#90DaysOfDevOpsChallenge #Git #GitHub #DevOpsJourney #HashnodeBlog #CollaborativeCoding