gitgithub
Ben Gorman

Ben Gorman

Life's a garden. Dig it.

Challenge

  1. Create a directory named softball/
  2. Initialize a git repo inside it.
  3. By default, the initial branch will be named main. Name it booger instead.

Solution

cd ~/Desktop
mkdir softball
cd softball 
git init --initial-branch=booger

Explanation

  1. cd (change directory) into ~/Desktop/

    cd ~/Desktop
  2. mkdir (make directory) softball/.

    cd ~/Desktop
    mkdir softball
  3. cd into softball/, since that's where we want the git repo to live.

    cd ~/Desktop
    mkdir softball
    cd softball
  4. Initialize the git repo with git init.

    cd ~/Desktop
    mkdir softball
    cd softball 
    git init --initial-branch=booger

    The --initial-branch flag lets us name the initial branch name something other than main (the default name).

How do I change the initial branch name after creating it?

You can rename the current branch using git branch -m <newname>. So,

git init --initial-branch=booger

could also be accomplished by

git init
git branch -m booger

git help

You can use

  • git <command> -h to see how to use a git command or
  • git help <command> to read the full docs regarding the command.