Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a new branch or renaming the default branch #960

Open
maneesha opened this issue Aug 10, 2023 · 3 comments
Open

Creating a new branch or renaming the default branch #960

maneesha opened this issue Aug 10, 2023 · 3 comments

Comments

@maneesha
Copy link
Contributor

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

@kekoziar
Copy link
Contributor

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?

@maneesha
Copy link
Contributor Author

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.

@kekoziar
Copy link
Contributor

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 ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants