A era do podcast

Muito se tem dito sobre este novo modelo de conteúdo, cada vez mais pessoas têm se rendido a ele, mas afinal, o que é podcast? “Podcast é o rádio do futuro.” a frase dita por Steve Jobs ilustra o…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




How to work with Git branches

A complete guide with the most common commands needed

Branches are one of the fundamentals you should be aware of when you are working with Git. That’s why in this tutorial we are going to review the multiple concepts related to Git branches and how they work.

Branches enable us to create separate contexts where we can try new things, or even work on multiple ideas in parallel. If we make changes on one branch, they do not impact the other branches (unless we merge the changes).

The default branch name is master. It doesn’t do anything special or have fancy powers. It’s just like any other branch. Many people designate the master branch as their “source of truth” or the “official branch” for their code base, but that is left to you to decide.

Note: in 2020, GitHub renamed the default branch from master to main. In Git default branch name is still master, although Git team is exploring a potential change.

Before we proceed to review the most important commands when working with branches, let’s talk about HEAD.

HEAD is simply a pointer that refers to the current “location” in your repository. It points to a particular branch reference. So far, HEAD always points to the latest commit you made on the master branch, but we can move around and HEAD will change.

HEAD pointing to the latest commit

As you can see in the above image, each point indicates a commit done in a specific branch. There might be multiple branches and HEAD can move between them. Whenever you want to know which state HEAD is currently in, and what it's referencing, the simplest way is to type git status in your terminal. Git will let you know the status of your entire Working Tree including Index (Staging area), but also the state of HEAD.

Now that we have a better idea about HEAD, let’s review some of the most important commands for Git branches:

Add a comment

Related posts:

Top 3 APIs To Get Data From Cairns Airport

Cairns Airport is an international airport in Queensland, Australia. It dates back to 1928 with a crash landing by pilot Tom McDonald. Subsequently, the airport was used for exercises by the Royal…

The Side Hustle Arms Race

Who among us did not start a pandemic podcast? If not a podcast, then it was a newsletter or an online Etsy store. Perhaps you launched a Patreon or promoted your pop-up restaurant on Instagram. The…

Bing Chat Copilot Sidebar

Scroll down to see more about privacy and terms of use, plus whether you want to give Microsoft access to your browser content for better responses. Here you can ask ChatGPT to write content for you…