swcarpentry / git-novice

Version Control with Git

Home Page:http://swcarpentry.github.io/git-novice/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Creating a new branch or renaming the default branch

maneesha opened this issue · comments

How could the content be improved?

In the Creating a Repository episode we say we are going to rename the default branch. However, command below (git checkout -b main) only creates a new branch called main; it does not change the default. It's not clear here that you must follow the instructions in the linked git setup lesson to change the default branch name.

Which part of the content does your suggestion apply to?

https://swcarpentry.github.io/git-novice/03-create.html

Thank you for the suggestion. That part of the lesson is already in an individual repository. "Next, we will change the default branch to be called main." is in relation to the repository just created, so the default branch is now main in that particular repository. I just tested it in a new repository, and once main is created, an error message is returned if trying to checkout master.

$ git init
Initialized empty Git repository in C:/Users/vlad/repos/test/.git/

vlad@MS-NADF4Y2  ~/repos/test (master)
$ git checkout -b main
Switched to a new branch 'main'

vlad@MS-NADF4Y2 ~/repos/test (main)
$ git checkout master
error: pathspec 'master' did not match any file(s) known to git

do you have a suggestion to make it clearer?

The lesson says:

Next, we will change the default branch to be called main.

The instructions in this particular lesson do not do anything to change the name of the default branch. Knowing that the default branch is likely already called main, instead of saying this is something we will do, we could say that we'll check to see what the branch name is, change it if needed, and then continue on.

Since there are no commits on master, executing git checkout -b main effectively changes the name of the default branch to main. master can no longer be accessed. So, the default branch of the repository is now main (or at least will be once a commit is added - technically at this point the repo doesn't have any branches, and executing git branch -a will return nothing, but this is far beyond a novice lesson).

I appreciate your suggestion to change the text to say we'll check the branch name; feel free to provide example text here if you want to workshop this, or submit a PR.

Also, I recognize that you have elevated privileges in the Carpentries repositories, but please submit PRs from your own forked repo instead of creating new branches in this lesson's repository. Unless there is a new workflow that I'm unaware of? @ErinBecker ??