QSD-Group / QSDsan

Quantitative Sustainable Design (QSD) of sanitation and resource recovery systems.
https://qsdsan.com
Other
30 stars 12 forks source link

Renaming the master branch to main #34

Closed yalinli2 closed 3 years ago

yalinli2 commented 3 years ago

Because of the historical origin of the branch (see the thread, and salient examples of master NOT being used in the "master copy" way), I think it'll be good to rename the default branch following the broad movement, including Git.

I'm opening this issue here for any comments, and will execute it in the following month or so following the renaming guidance if folks see so problem, thanks!

yalinli2 commented 3 years ago

Well I didn't receive any feedbacks, so I assume all is good and change the default branch name.

yalinli2 commented 3 years ago

It just occurred to me that the reason that git instruction didn't work well for me could be I had an outdated version of git (git version 2.21.1 (Apple Git-122.3), comes with the Mac), which is before git decides to move from master to main

I've changed the default branch name to main, but you need to manually update your local environment. You should see instructions the first time you visit the repository homepage (this is my, yours might be upstream instead of origin if you are using fork):

git branch -m master main
git fetch origin
git branch -u origin/main main

However, this didn't work for me at all, upon fetching, I got an error: fatal: couldn't find remote ref refs/heads/master

Took me some time to figure out, still not sure why the official method didn't work, but here's what ultimately helped me:

First used git remote show origin, there was a stale master branch:

* remote origin
  Fetch URL: https://github.com/QSD-Group/QSDsan.git
  Push  URL: https://github.com/QSD-Group/QSDsan.git
  HEAD branch: main
  Remote branch:
    refs/remotes/origin/master stale (use 'git remote prune' to remove)
  Local branches configured for 'git pull':
    beta merges with remote beta
    main merges with remote master
  Local refs configured for 'git push':
    beta pushes to beta (up to date)
    main pushes to main (up to date)

Then prune it, used the dry-run flag for cautious purpose: git remote prune origin --dry-run

Git warned that my head will become dangling,

Pruning origin
URL: https://github.com/QSD-Group/QSDsan.git
 * [would prune] origin/master
 refs/remotes/origin/HEAD will become dangling!

I pruned it anyway (git remote prune origin), as suggested in the post above, I can fix this

And I tried git remote set-head origin -a, but git threw me an error:

error: Not a valid ref: refs/remotes/origin/main
origin/HEAD set to main

And master was still in git remote show origin:

* remote origin
  Fetch URL: https://github.com/QSD-Group/QSDsan.git
  Push  URL: https://github.com/QSD-Group/QSDsan.git
  HEAD branch: main
  Local branches configured for 'git pull':
    beta merges with remote beta
    main merges with remote master
  Local refs configured for 'git push':
    beta pushes to beta (up to date)
    main pushes to main (up to date)

But when git checkout main, finally I got a prompt:

Switched to branch 'main'
Your branch is based on 'origin/master', but the upstream is gone.
  (use "git branch --unset-upstream" to fixup)

After git branch --unset-upstream, now everything is normal git remote show origin

* remote origin
  Fetch URL: https://github.com/QSD-Group/QSDsan.git
  Push  URL: https://github.com/QSD-Group/QSDsan.git
  HEAD branch: main
  Local branch configured for 'git pull':
    beta merges with remote beta
  Local refs configured for 'git push':
    beta pushes to beta (up to date)
    main pushes to main (up to date)

Yay! 🎉