DevOps90DaysChallenge

DevOps90DaysChallenge

Ā·

3 min read

Hi šŸ‘‹there,

Now we are on the Day 11 task

Advance Git & GitHub**(Git Stash,Cherry-pick,Resolving Conflicts)**

Checkout the below link for Day 12 task:

https://github.com/LondheShubham153/90DaysOfDevOps/blob/master/2023/day11/tasks.md

Git Stash:

Git stash is a command that allows you to temporarily save changes you have made in your working directory, without committing them. This is useful when you need to switch to a different branch to work on something else, but you donā€™t want to commit the changes youā€™ve made in your current branch yet.

Git #SourceTree | Git stash - Save changes away for later use. #Stashing -  YouTube

To use Git stash, you first create a new branch and make some changes to it. Then you can use the command git stash to save those changes. This will remove the changes from your working directory and record them in a new stash. You can apply these changes later. git stash list command shows the list of stashed changes.

You can also use git stash drop to delete a stash and git stash clear to delete all the stashes.

Cherry-pick:

Git cherry-pick is a command that allows you to select specific commits from one branch and apply them to another. This can be useful when you want to selectively apply changes that were made in one branch to another.

Git Cherry Pick - How to use the "cherry-pick" command in Git | Learn  Version Control with Git

To use git cherry-pick, you first create two new branches and make some commits to them. Then you use the git cherry-pick <commit_hash> command to select the specific commits from one branch and apply them to the other.

Resolving Conflicts:

Conflicts can occur when you merge or rebase branches that have diverged, and you need to manually resolve the conflicts before it can proceed with the merge/rebase. git status command shows the files that have conflicts, the git diff command shows the difference between the conflicting versions and the git add command is used to add the resolved files.

How to Resolve Merge Conflicts in Git Tutorial | DataCamp

Task-01

  1. Create a new branch and make some changes to it.

  2. Use git stash to save the changes without committing them.

  3. Switch to a different branch, make some changes and commit them.

Task-02

  • In version01.txt of development, the branch adds the below lines after ā€œThis is the bug fix in development branchā€ that you added in Day10 and reverted to this commit.

  • Line2>> After bug fixing, this is the new feature with minor alterationsā€

  • Commit this with the message ā€œ Added feature2.1 in development branchā€

  • Line3>> This is the advancement of the previous feature

  • Commit this with the message ā€œ Added feature2.2 in development branchā€

    • Line4>> Feature 2 is completed and ready for release

    • Commit this with the message ā€œ Feature2 completedā€

      • All these commits messages should be reflected in the Production branch too which will come out from the Master branch (Hint: try to rebase).

        Task-03

      • ā€¢ In Production branch Cherry pick Commit ā€œAdded feature2.2 in development branchā€ and added below lines in it:

        ā€¢ Line to be added after Line3>> This is the advancement of previous feature

        ā€¢ Line4>>Added few more changes to make it more optimized.

        ā€¢ Commit: Optimized the feature

      • After committing in main branch, switch to the different branch And run the cherry-pick command git cherry-pick

  • Please, feel free to drop any questions in the comments below. I would be happy to answer them.

  • If you find this post helpfulšŸ˜ŠšŸ™‚, please follow and click the heartā¤ā¤ button below to show your support.

  • _ Thank you for reading

    _sandhya kumari

Ā