DEV Community

Raymon Schouwenaar for Mr Frontend

Posted on • Originally published at Medium on

Git 101 — STEP 4: merging branches, merge conflicts & cherry-pick

Today I want to show you how easy it is to merging branches, fix a merge conflict and how to use cherry-pick to get any commit your local branch!

Let’s get fired up and hit the terminal 🔥

In the video, I show you everything that I know. Below the video, you can check the notes with all the commands you need.

1 Git pull a different branch into current branch!

Make sure your both branches are up to date on the remote!

git merge tryout
Enter fullscreen mode Exit fullscreen mode

Now you can test if your code still works! If it works it push it to the remote!

2 After successfully merged, delete another branch

Use the following command like we talked about in the previous video, to delete the branch.

git branch -d tryout
Enter fullscreen mode Exit fullscreen mode

3 What if you get a merge conflict?

Sometimes it happens that someone else changed the same row as you did. When you pull the remote you will get a merge conflict.

The easiest way to fix this is just manually by checking your code. After you fixed it, commit this change and push it to the remote!

4 What if you want to have a specific commit change from another branch?

This is what we called cherrypicking. With cherry-pick you can pick the commit you want, to pull it into your local branch where your working on.

Just find the commit id and just this command.

git cherry-pick commitId
Enter fullscreen mode Exit fullscreen mode

Do you need some help?

If your working with Git, but getting stuck? Please let me know in the comments or hit me on twitter @frontendmr and I would ❤️ to help you out!

Did you liked this post? Please share it around 🙏

Originally published at Mr Frontend Blog.

Top comments (1)

satizzzzz profile image
Sathish Kumar

How a git merge after cherry-pick of same branch will work?