Closed JKrag closed 3 years ago
Maybe we can work around this by actually setting init.defaultBranch
to master
locally in the shared make-setup.sh
script. But I haven't tested yet, and I am a bit uncertain as to whether this works as we are talking about a init
setting that obviously has to be set somewhere before we actually run git init
, so we can't actually set in inside the individual exercise
repos.
I looked a step further, and it turns out that since git 2.28 (where the init.defaultBranch
showed up), git init
has also been expanded to support:
git init --initial-branch=[BRANCHNAME]
I guess this should make it rather easy to always create the repos with (currently) master
and later probably main
.
The decision to make that move is not in scope of this issue. It will probably depend on when Git decides to change the default. It will also require a thorough search/replace of al the exercise instructions.
I realised that we can not currently use the --initial-branch
feature as that would fail with older versions of Git, but I found another solution, by setting the init.defaultBranch config inline when calling git init
.
I have now created a branch where this is fully implemented. https://github.com/eficode-academy/git-katas/tree/default-branch-handling
For all Shell scripts, it refers to a global DEFAULT_BRANCH variable in utils.sh-
For the PS scripts, I didn't have an easy way to do that (and I am not experienced with PS), so on those it is currently hardcoded to master
.
The only reason I have not yet opened a PR for this branch, is that it is building on top of the improve-testing
branch that isn't merged yet.
For technical reasons, I had to include this change in #299 to make it build. The actual commit regarding the defaultBranch changes can be found here: https://github.com/eficode-academy/git-katas/pull/299/commits/9f5ca7470c46d1f52eecf5e573dbab2f1fa3a502
So there will not be a separate PR for this change. Please go to #299 to comment if relevant.
The change has been merged as part of #299 so I am now closing this issue.
Some users have set a global config to default to e.g. main instead of master, and this makes a lot of the setup scripts fail when they do a checkout master after creating a branch.
We need to come up with a clean solution for this.
Expanding:
Recent versions of Git (mine is 2.30.1 right now) have started posting the following warning when you run
git init
:This means that a lot of users might now be setting their
init.defaultBranch
to something other thanmaster
and thus he current scripts will fail.