This site runs best with JavaScript enabled.
Do you love what we do?Become a patronat Patreon❤️

Git 101 – Step 3: branches

Raymon S

December 12, 2017


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 😉

https://youtu.be/Kf4sjbE-G24

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!

git branch```
<strong>Update your local branches</strong>
So let's face it! Sometimes your branches are behind of the branches on the remote. So to update this list, use this command.

git fetch origin`

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```
<strong>Push to a branch</strong>
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!

git push origin branch_name`

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.

git pull origin branch_name```
<strong>Switch branch</strong>
Sometimes you want to switch to another branch for some reason. Just checkout the other branch with this command.

git checkout branch_name`

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!

git branch -d branch_name```
<h2>Do you need some help?</h2>
If your working with Git, but getting stuck? Please let me know in the comments or hit me on twitter <a href="https://twitter.com/frontendmr" target="_blank" rel="noopener">@frontendmr</a> and I would &#x2764;&#xfe0f; to help you out!
Did you liked this post? Please share it around &#x1f64f;
<div class="grammarly-disable-indicator"></div>
export const _frontmatter = {"ID":1243,"title":"Git 101 – Step 3: branches","author":"Raymon S","excerpt":"","slug":"2017/12/git-101-step-3-branches/","published":true,"date":"2017-12-12T10:03:07.000Z"}
Do you love what we do?Become a patronat Patreon❤️
Share article