Git 101 — Step 3: branches

Image for post
Image for post

This time we are going to talk about how you can handle branches with Git on the terminal 🚀. For a full explanation check the video 😉

What is a Git branch?

A branch is a separate workspace, it’s like a bucket where you can fiddle around without screwing the production application.

You create branches when you are gonna make new functionality or features for your application.

So let’s get started with branches!

Check your branch

Check your branches

If you want to know on which branch you are currently working? This command will tell you!

Update your local branches

So let’s face it! Sometimes your branches are behind of the branches on the remote. So to update this list, use this command.

Do something with your branch!

Create branch

Now we want to create a branch, because we want to fiddle around without the code. Pretty easy command.

Keep in mind to use “-b” instead of the “-d”!! 😅, because the “-d” will delete your branch!

git checkout -b branch_name

Push to a branch

When you made some changes, staged them and added a commit message, we want to push our branch to the remote. Use this command for it!

Pull changes from a branch

When your team member made some change to the same branch you are working on. You can pull those changes from the remote into your local branch with this command.

Switch branch

Sometimes you want to switch to another branch for some reason. Just checkout the other branch with this command.

Delete local branch

Be careful with this command! If you didn’t pushed the changes in this branch, all the changes will be lost with this command!

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.

Written by

I write stories about Frontend Dev, JavaScript, Typescript, Angular, NodeJS, Serverless Functions, JAM Stack, FaunaDB, Netlify, Apple, iOS— https://byrayray.dev

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