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

Image for post
Image for post

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 🔥

1 Git pull a different branch into current branch!

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

git merge tryout

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

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

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 🙏

I write stories about Frontend Dev, JavaScript, Typescript, Angular, NodeJS, Serverless Functions, JAM Stack, FaunaDB, Netlify, Apple, iOS—

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store