set meaningful defaults for git in post-create #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new function to the
.devcontainer/post-create.sh
script for setting global Git configuration options if they do not already exist. Additionally, it includes several calls to this new function to set specific Git configurations.This is to overcome some user challenges, where git cannot commit because a
user.name
anduser.email
is not set in~/.gitconfig
. VSCode copies these settings from the host, if they are configured there, or the user has properly set up VSCode already, then it is also correctly set in the container. However, if they don't set it (newbie user), then this sets them to defaults that work.It also configures the container user's git to handle the CRLF/ LF issue of compatibility between Linux and Windows. This should work, but I don't have Windows to test it.
Enhancements to
.devcontainer/post-create.sh
:add_git_config_if_not_exist
function to check and set global Git configuration options if they are not already set.add_git_config_if_not_exist
function:core.autocrlf
set toinput
core.safecrlf
set towarn
pull.rebase
set tofalse
user.name
set toAnonymous L-CAS DevContainer User
user.email
set tonoreply@lcas.lincoln.ac.uk
init.defaultBranch
set tomain