• Home
  • About
    • Delta Media Hosting
    • Delta Media Core-business
    • Delta Media
    • Adverteren grote fraude
    • Menu POS
    • Delta Global Security
    • Delta Evenementen
    • LinkedIn
    • Facebook
    • Facebook Group
    • Twitter
    • Terms & Policy
    • Contact
    • .
  • Online Project
  • Delta Online Streaming
    • Sidney Samson Project
    • Sidney Samson Site
    • DJ Online Streaming
    • DJ online Streaming Platform
    • DJ Online Streaming Site
    • Online Music Streaming
    • The Online Streaming Platform
    • Online Streaming Radio
    • Streaming Service
    • Digitale Radio
    • DJ Video Platform
    • Online Streaming Service
    • Online Streaming Info
    • Online Streaming Platform
    • More Ledo links
  • Marketing Platform
    • Delta Media Strategie Modules
    • Online Marketing
    • Delta Social Media
    • Delta Media Service
    • Delta media Platform
    • Delta Marketing Platform
    • Online business marketing
    • Online Business
      • Worth for free now
      • Work from Home 2020
      • Gadgets
      • All about Windows
      • about Whatsapp
      • Whats the
      • About websites
      • New Ways
      • New Way of Watching
      • Virtual
      • Website
      • All about Video
      • How to Use
      • YouTube Info
      • All about Twitter
      • The Best of
      • About Apps
      • Google News
      • For Free
      • About This
      • Need More
      • Why should you
      • Iphone news
      • Interesting News
      • About Amazone
      • Some tips
      • About Netflix
      • All about Music
      • About Facebook
  • Luxury Platform
    • The Indulgence Business site
    • The Luxury Web site
    • The Ultimate Indulgence
    • The Indulgence Site
    • The Ultimate Luxury Information site
    • Online luxury
  • Projecten
    • Global Diamond Security
    • Aqualith Project
    • Delta Online Projects
    • Delta Media
    • Delta Media Projects
    • Crypto info
      • What is Cryptocurrency
      • Delta Media ICO systeem
      • Cryptocurrency Information
      • About miners
      • Best Bitcoin Bokers
      • Overview Cryptocurrency
      • BLOCKCHAIN WEB PLATFORM
      • Delta Media ICO Cryptocurrency
      • Bitcoin Ticker
      • ICO and Cryptocurrency modules
      • Cryptocurrency, Blockchain, Bitcoin modules
      • Delta Buy & Sale Token
      • Buy and sell digital currency module
      • ico – Crypto BlockChain Parallax module
      • Exchange Cryptocurrency module
  • Nieuws
    • RegioTV Nieuws
    • Regionaal Nieuws Platform
    • Nieuws Regio’s Tiel
    • RegioTV Buren
    • RegioTV Neder-Betuwe
    • Regionaal Nieuws Tiel
    • Micro Locals Nieuws
    • Micro Locals project
    • Lokale CSM systeem
    • RegioTV nieuws
    • Politiek Nederland
    • Politiek Gelderland
    • Politiek Tiel
    • Regio Nieuwsberichten Tiel
    • Regionaal nieuws
    • Regionaal video nieuws
    • RegioTV Nieuws & info
    • Regio Nieuws
    • Online video nieuws
    • Online Nieuws
    • Nieuws online RegioTV
    • Regionale content video
  • Promotie
  • Ads prices
    • Online Blog promotion price
    • Online web sites prices
    • Global Promotion Platform
  • Home
  • Delta Media News
  • How to Create a New Branch in Git | MakeUseOf
April 18, 2021

How to Create a New Branch in Git | MakeUseOf

How to Create a New Branch in Git | MakeUseOf

by rudy deighton / Tuesday, 10 November 2020 / Published in Delta Media News

Branches are central to the concept of version control in programming, and Git in particular. This starter article tells you what a branch is and how to create one using a number of different tools.

What is a Git Branch?

In version control systems, the term branch is used as an analogy with trees in the sense that each branch emerges from another, eventually ending up back at the trunk. Branches allow you to create individual lines of development, in order to work on them in isolation without disturbing other work.

Related: How to Use Git Branches to Structure Your Programming Project

Using Git, you’ll be working on the master branch by default, whether you’re aware of it or not. This is often referred to as your active, current, checked-out, or HEAD branch. At any time during your development cycle, you can create a new branch and carry out separate work in each branch, from that point onwards.

Creating a New Branch on the Command Line

The command-line Git program offers the most power and flexibility, but there’s a lot to learn. If you’re comfortable digging around the man pages and make heavy use of Git, it’s a great option.

Use the git branch <branchname> command to create a new branch with the given name:

$  git branch dev
Branch 'dev' set up to track local branch 'master'.

This branches from the current branch, so make sure you’ve switched to the one you want to branch from before you execute that command.

You can list all branches and confirm the new one has been created using git branch without any arguments:

$  git branch
1 dev
2 * master

You can see more information, including which branch another one tracks, using the -vv flag:

$  git branch -vv
1 dev d1a9e5b [master] commit comment
2 * master d1a9e5b commit comment

If you try to create a branch before the first commit, you’ll get an error message like:

fatal: Not a valid object name: 'master'.

If you try to create a branch using a name that already exists, you’ll get an error message like:

fatal: A branch named 'dev' already exists.

The git branch command creates a new branch pointing to the same commit you’re currently working on. However, your working copy will still be pointing at the master branch. To switch to the new branch you just created, use git checkout:

git checkout dev

The term checkout might be confusing if you’re used to other version control systems; in Git, checkout refers to switching the currently active branch. Since you’ll usually want to switch to a new branch once it’s created, there’s a shortcut for the whole process:

git checkout -b dev

That command means “create a new branch called ‘dev’ and switch to it immediately”. It’s the equivalent of:

git branch dev
git checkout dev

In fact, you can even use git checkout to create a branch from any other, not just the one that is currently checked out. For example, to create a new branch called another, from the branch named dev:

git checkout -b another dev

Creating a New Branch Using GitHub Desktop

Another way to create Git branches on Windows or macOS is using GitHub Desktop, the official graphical user interface (GUI) program provided by GitHub. Using a GUI is perfect for beginners, and those who have nightmares when someone whispers the word Vim.

GitHub Desktop will always show your current branch in the main toolbar:

Click on that main toolbar button to show details of the repository’s branches, including the option to create a new branch:

Note that, if you start typing a branch name with no matches, GitHub Desktop prompts you to create a new branch and shows the keyboard shortcut to do so—useful if it’s really the kind of thing you find yourself doing a lot:

You can also start by pressing the New Branch button immediately. Whichever route you take, you’ll end up with a dialog to confirm the new branch name:

Your new branch will always be based on whichever branch was active when you created it. GitHub Desktop will switch to your new branch which will automatically track the branch you created it from.

Creating a New Branch Using Tower

Other GUIs are available from third-parties. Tower is free for a 30-day trial period and is available on macOS and Windows.

To create a new branch from the currently checked-out branch, select Create New Branch from the main Repository menu:

To create a new branch from any available branch, right-click on the branch in the left-hand sidebar and select Create New Branch from <branch name>:

Note that, in either case, you can enable the branch as a tracking branch, or change the Starting Point to any branch available:

Creating a New Branch Using GitKraken

GitKraken is another popular GUI that can seem intimidating at first, but it does a good job of visually representing key Git concepts, including branches. GitKraken is free for open-source use and is available for Windows, Mac, and Linux.

Make sure you’re working with the correct active branch; it’s the one highlighted in the branch listing in the left-hand sidebar:

To create a new branch, click the branch icon in the main toolbar:

Enter your branch name and hit ENTER:

The new branch will automatically be checked out and you’ll receive a notification on the right-hand side of the screen.

Creating a New Branch on GitHub

As an alternative to running a local app, you can host your repository on one of two popular Git-supporting web apps. The first, GitHub, is a very popular option with the open-source community.

GitHub displays your current (active) branch in your repository view, near the top-left:

Click the button to display existing branches:

Type the name of your new branch and note that you are given the option to create it from the current branch:

Once created, your new branch becomes active.

Creating a New Branch on Bitbucket

Bitbucket is another popular version control web app that offers free accounts with an unlimited number of private repositories.

From any page within your repository, select the Branches item from the menu on the left:

Click the Create branch button in the top-right. Enter the new Branch name and click Create. If you need to branch from anywhere other than master, change the From branch first:

Bitbucket makes it easy to select a Type which is a prefix added to the branch name that can encourage a more organized approach to branches. It’s just a convention, rather than a built-in Git feature, but it can prove useful.

Once created, Bitbucket displays a view of your new branch:

Bitbucket screenshot showing new branch pageLearn to Branch Out With Git

Git is all about branches: they’re cheap to create and they allow multiple streams of work to coexist, ready to be merged when complete. Once you’re familiar with creating, switching, and merging branches, you’ll be well on the way to using Git to its full potential.

MakeUseOf – Feed

  • Tweet
Tagged under: Branch, Create, MakeUseOf

About rudy deighton

What you can read next

The 5 Best Desktop Apps to Add Instagram Filters to Your Photos
How to Sync Music With Your Android Phone or Tablet
The Countdown to Black Friday Is On! Here Are the 10 Best Deals

Rudy Deighton Corporate Blog

  • Apple Highlights Environmental Benefits of Not Selling iPhones With Power Adapters

    Following the launch of the iPhone 12 last year...
  • The 6 Best Laptop Fan Control Apps to Keep Your Laptop Cool

    Don’t have a dedicated fan control softwa...
  • How to Configure Display Scaling on Windows 10 for High-DPI Monitors

    It is not a secret that Windows doesn’t look go...
  • How to Use CSS box-shadow: 13 Tricks and Examples

    CSS is the language developers use to style a w...
  • You Can Now Use NVIDIA’s GeForce Experience to Optimize Creative Apps

    The April 2021 update of the NVIDIA Studio Driv...
  • Microsoft Edge Canary Arrives on Android

    Microsoft’s Edge browser is its best offe...
  • Facebook Is Now Powered Entirely by Renewable Energy

    Over the last few years, tech giants have been ...
  • Google Search Launches a New Shortcut for Editing Your Query

    Google’s search results page on desktop n...
  • Google Chrome Gets New Features to Boost Your Productivity

    Google has announced some new productivity feat...
  • Reddit Invites Everyone Into Its Bug Bounty Program

    Fancy yourself a dab hand at breaking into webs...
  • Why You Still Can’t Get Hold of a PS5

    The PS5 has been out for a while now. Despite t...
  • Xgimi’s New Horizon Projectors Bring 4K for Under $2,000

    If you’re looking to add ultra high defin...
  • Microsoft Releases Windows 10 Insider Preview Build 21359

    Microsoft’s Windows 10 Preview builds are...
  • Celebrate Earth Day With These 5 Eco-Friendly Mobile Apps

    April 22nd marks Earth Day across the globe, an...
  • The 7 Best Hidden Features in Microsoft Edge

    Microsoft’s all-new Edge browser has managed to...
  • Artfol Finally Makes Its Long-Awaited Debut on iOS

    There isn’t one standout online art platf...
  • Anker Introduces an Affordable, AI-Enabled Webcam for Home Offices

    Anker is expanding its growing lineup of home o...
  • You Can Now Store PS5 Games on External USB Drives

    Sony has made it easier for you to store more P...
  • Siri Reveals When the Next Apple Launch Event Is Happening

    According to Siri, the Apple Event 2021 appears...
  • The FCC Launches a Speed Test App to Measure Broadband Availability

    A new app from the Federal Communications Commi...
  • Facebook Makes It Easier to Find Out Where to Get Your COVID-19 Vaccine

    More and more Americans are becoming eligible t...
  • LG Confirms List of Phones Set to Get Android 12 and Android 13

    LG recently announced that it’s dropping ...
  • Microsoft’s Latest Attack Ad Rips Into the iPad Pro

    It might be 2021, but to someone in Microsoft&#...
  • Sony May Be Planning to Bring Its "Most Popular Franchises" to Mobile

    Sony Interactive Entertainment is currently loo...
  • How to Include Emojis in Your Python Code

    An emoji is a small digital image used to expre...
  • The Samsung Galaxy S21 FE Has Leaked in Renders

    Renders of Samsung’s upcoming “Fan ...
  • Study: The US Is Spreading COVID-19 Misinformation to Canada

    Canadian prime minister Justin Trudeau once des...
  • The Official 2021 White House Portraits Were Shot With the Sony a9 II

    Weeks after the inauguration of a new US presid...
  • The 5 Best Music Visualizers for Android

    Music visualizers can help you bring your music...
  • Logitech Discontinues Its Harmony Line of Universal Remotes

    Logitech has axed its Harmony remote lineup for...
  • Google Announces the Pixel 5a by Denying It Has Cancelled the Pixel 5a

    Following reports that the Pixel 5a launch has ...
  • Report: Hackers Are Sending Fake Job Offers on LinkedIn to Try and Steal Your Data

    The unfortunate rise in unemployment caused by ...
  • 3 Great Tools to Keep You Focused While Working From Home

    Whether you’re working from home, writing...
  • The 7 Best Wireless Lavalier Microphones

    Summary List 9.60/10 1. Premium pick: Shure GLX...
  • Facebook Starts Applying Labels to Pages to Avoid Confusion

    Facebook is slowly adding new labels to certain...
  • How to Manage Tab Groups in Google Chrome

    Tab Groups from Google Chrome are changing the ...
  • 5 Exciting Linux Distro Updates to Look Forward to in 2021

    We’re four months into 2021 and a lot of ...
  • Google I/O Returns in May, Virtually, and Free for the First Time

    Google has announced that it will be holding I/...
  • Clubhouse Now Lets You Send Payments to Creators

    Online voice chat has become a more widespread ...
  • How to Set Up Strava and Record Your Walks

    Monitoring your progress can be a great motivat...

DELTA MEDIA ONLINE MARKETING PLATFORM
An Arte di Riunire Investments GmbH Division

Office:
Delta Media

Arte di Riunire Investments GmbH

Address: Lood 207F

Postcode: 3803 Beatenberg (Swiss)

email: rudydeighton@hotmail.com

rudydeighton@deltamediagbe.com

 

 

Online Platform

Menu POS Systeem

  • GET SOCIAL

© 2014 Delta Media - Arte di Riunire Investments GmbH Division - SWISS All Rights Reserved

TOP