Day 11: Advance Git & GitHub for DevOps:Part-2.

Day 11: Advance Git & GitHub for DevOps:Part-2.

Here I have completed the task related to Advanced Git & GitHub Commands and some working examples with it.

Day 11 Task:

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.

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.

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 git can proceed with the merge/rebase. git status command shows the files that have conflicts, git diff command shows the difference between the conflicting versions and git add command is used to add the resolved files.


Task-01

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

branch change

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

1

git stash

  • Use git stash pop to bring the changes back and apply them on top of the new commits

git stash pop

  • Use git stash push to delete all the thing which are in stash.

git stash push


Task-02

  • In version01.txt of the development branch add the below lines after “This is the bug fix in the development branch” that you added on Day10 and reverted to this commit.

  • Line2 >> "After bug fixing, this is the new feature with minor alteration” Commit this with the message “Added feature2.1 in development branch”

2

  • Line3>> This is the advancement of the previous feature. Commit this with message “Added feature2.2 in development branch”

3

  • Line4>> Feature 2 is completed and ready for release. Commit this with a message “Feature2 completed”

4


Task-03

  • In the Production branch Cherry pick Commit “Added feature2.2 in development branch” and added below lines in it:

Screenshot from 2023-03-19 16-22-26

Commit: Optimized the feature.


Happy Learning :)

Did you find this article valuable?

Support Rohit Rajput by becoming a sponsor. Any amount is appreciated!