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

Change the default branch name for new Rails projects from master to main #40214

Closed
jayqui opened this issue Sep 10, 2020 · 7 comments · Fixed by #40254
Closed

Change the default branch name for new Rails projects from master to main #40214

jayqui opened this issue Sep 10, 2020 · 7 comments · Fixed by #40254

Comments

@jayqui
Copy link

jayqui commented Sep 10, 2020

Steps to reproduce

$ rails new temp_experiment
# app is created
$ cd temp_experiment
$ cat .git/HEAD
ref: refs/heads/master

Expected behavior

.git/HEAD should contain ref: refs/heads/main

References

Actual behavior

.git/HEAD contains ref: refs/heads/master

System configuration

Rails version: 6.0.3.3

Ruby version: 2.7.1p83

@eileencodes
Copy link
Member

Hey @jayqui thanks for opening this. We discussed this as a team awhile back and decided to wait until GitHub was finished building out the feature to make the transition smooth. We have a lot of open PRs and changing the branch name would mean none of those PRs are mergable without intervention from the original author which can cause quite a bit of friction. I will leave this issue open until we've made the switch. Thanks again!

@eileencodes
Copy link
Member

@jayqui I misunderstood you were also talking about what happens when you build a new Rails project. I think we can change that without waiting for the GitHub feature. Do you want to open a PR?

@matthewd
Copy link
Member

Ah, I'd missed that distinction too.

I slightly worry about ignoring someone's explicitly configured init.defaultBranch=trunk, or whatever... but that's something we could explore on a PR.

(If the report is that we ignore a relevant ~/.gitconfig, then that's 110% a bug, but I don't think that's the case here?)

@prateekkish
Copy link
Contributor

@eileencodes Here's a PR #40254

I've taken into account the user's .gitconfig as per @matthewd's comment.

@ghost
Copy link

ghost commented Oct 16, 2020

I had some concerns about the approach here in this issue that I wrote about on the PR, I'll post them here as well.

If init.defaultBranch is already set rails new already creates a project with the custom default branch name. I think changing the default behaviors for a new project created with rails new that differs from git init would be undesirable because it would be unexpected. It's likely that most users wanting a custom default branch name would have already set init.defaultBranch, whereas those leaving it unset likely expect "master" to be the default.

Basically I think it's already viable to easily switch to main as a default for new projects with the generator as is, it already just works with non standard default branch names, but a change like this would mess with workflows that expect/need the default to be master (for example deployment scripts).

I think it would be proper for rails new to have the same effect as git init as far as the default branch naming, if git is configured to use main as default rails should (and does) respect that, if not rails should still leave it alone because not setting init.defaultBranch is inferring init.defaultBranch=master.

@rails-bot
Copy link

rails-bot bot commented Jan 14, 2021

This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.
If you can still reproduce this error on the 6-1-stable branch or on master, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.

@rails-bot rails-bot bot added the stale label Jan 14, 2021
@rails-bot rails-bot bot closed this as completed Jan 21, 2021
@jayqui
Copy link
Author

jayqui commented Jan 23, 2021

Discussion is ongoing in the PR. I'm new around here and unsure whether this issue should be re-opened. In any event, I cannot find a way to re-open it, so perhaps there's my answer.

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

Successfully merging a pull request may close this issue.

4 participants