You need Git to get the code, to push it to KIMS's Git, and (on Windows) for Git Bash. Any recent version works; the repository asks for nothing specific.
#Install
# Ubuntu or Debian
sudo apt update && sudo apt install -y git# RHEL, Rocky, Alma, Fedora, Amazon Linux 2023
sudo dnf install -y gitbrew install gitWithout Homebrew, xcode-select --install installs Apple's Command Line Tools, which include git. Homebrew itself is installed from https://brew.sh.
winget install -e --id Git.Git --source wingetThe alternative is the installer from https://git-scm.com/download/win. Either way you get Git for Windows, which includes Git Bash, openssl, sed and the Git Credential Manager.
During the installer's questions (if you run it by hand), the defaults are fine. Two of them matter for this project:
- "Configuring the line ending conversions": the default, "Checkout Windows-style, commit Unix-style line endings" (
core.autocrlf=true), works with this repository because its.gitattributesforces LF where it matters. See Line endings. - "Choosing the default editor": pick one you know (Notepad or VS Code), not Vim, unless you use Vim.
Open a new terminal window after installing, so the new PATH is picked up.
#Check
git --versionYou should see git version 2.x (for example git version 2.52.0; Windows adds .windows.1).
On Windows, also open Git Bash from the Start menu and run git --version there. A terminal window opens and prints the same version.
#Set your name and email
Git refuses to commit without them. They are written into any commit you make (you should rarely need to commit on site; you mostly push existing commits).
git config --global user.name "<YOUR_NAME>"
git config --global user.email "<YOUR_EMAIL>"Check with git config --global --list.
#Credentials
#Credentials for GitHub (getting the code)
The code is at https://github.com/DayntTech/kims-v2, a private repository: you need a GitHub account with access, and git needs a way to authenticate. GitHub no longer accepts your account password for git. The simplest way on every system is the GitHub CLI, which signs you in through the browser and sets git up to use it:
# Ubuntu or Debian: GitHub's apt repository
(type -p wget >/dev/null || sudo apt install -y wget) && sudo mkdir -p -m 755 /etc/apt/keyrings \
&& wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update && sudo apt install -y gh# RHEL family
sudo dnf install -y 'dnf-command(config-manager)' && sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo && sudo dnf install -y ghbrew install ghwinget install -e --id GitHub.cliThen, in a new window:
gh auth login
gh auth setup-gitAnswer: GitHub.com, HTTPS, "Login with a web browser". gh auth status should then say Logged in to github.com account <you>.
If you cannot install gh: on Windows, Git Credential Manager (included) opens a browser sign-in the first time you clone. On macOS, git uses the Keychain (osxkeychain) and asks for a username and a personal access token (GitHub, Settings, Developer settings, Personal access tokens) as the password. On Linux, use a personal access token with git config --global credential.helper 'cache --timeout=28800' so it is remembered for 8 hours without being written to disk.
If GitHub cannot be reached at all from where you are, clone from the git bundle in the handover instead (Get the code).
#Credentials for KIMS's Git (pushing)
KIMS's Git may be GitHub, GitLab, Bitbucket, Azure DevOps or a self-hosted server. Ask KIMS which, and whether they want HTTPS with a token or SSH. Git Credential Manager (Windows, and installable on macOS and Linux) handles most hosted services through a browser sign-in. For SSH:
ssh-keygen -t ed25519 -C "<YOUR_EMAIL>"
cat ~/.ssh/id_ed25519.pubssh-keygen -t ed25519 -C "<YOUR_EMAIL>"
cat ~/.ssh/id_ed25519.pubssh-keygen -t ed25519 -C "<YOUR_EMAIL>"
Get-Content $HOME\.ssh\id_ed25519.pubGive KIMS the .pub line (the public key) to add to your account on their Git. Never send the file without .pub. Test with ssh -T git@<KIMS_GIT_HOST>. The push itself is on Push the code.
#Line endings
#What the repository does
Linux and macOS end lines with LF; many Windows tools write CRLF. A shell script with CRLF fails on Linux with /bin/sh^M: bad interpreter or cannot execute: required file not found. This happened on the earlier platform: a Jenkins bootstrap script checked out on Windows with CRLF stopped Jenkins from starting.
So kims-v2/.gitattributes forces LF on checkout, whatever your settings, for:
*.sh text eol=lf
jenkins/** text eol=lf
infra/lib/functions/** text eol=lf
infra/lambda/** text eol=lf
scripts/deploy/** text eol=lf
scripts/bundle-hash.mjs text eol=lf*.sh covers deploy/jenkins/check-environment.sh, deploy/entrypoint.sh and deploy/kind/*.sh. Files Node runs (.ts, .mjs, .js) are left to core.autocrlf, because Node reads CRLF fine.
deploy/cloudfront/** (the CloudFront function you paste into the console) is not in main's list; the windows-fixes branch adds it. CloudFront accepts the code with CRLF, so on main this is harmless, but copy the function from a Linux or macOS checkout, or from the web view of KIMS's Git, if you want it byte-for-byte.
The Jenkins site job also drops carriage returns from the kims-site-env credential, so a settings file saved on Windows works.
#Your settings
git config --global core.autocrlf inputgit config --global core.autocrlf inputgit config --global core.autocrlf trueinput on Linux and macOS converts any CRLF to LF when committing and never adds CR. true on Windows is Git for Windows's default: LF in the repository, CRLF in your working files except those .gitattributes forces to LF.
#"Modified" files that you did not change
On Windows with core.autocrlf=true, git status may list files as modified when only their line endings differ (seen with packages/db/src/cli.ts). Check:
git diff --ignore-cr-at-eol --statNo output means the differences are line endings only. Do not commit them. To make them go away:
git add --renormalize .
git statusIf they are still listed, git checkout -- <file> restores the committed version (this discards any real change you made to that file).
#Long paths on Windows
Windows limits paths to 260 characters unless long paths are switched on. A deep node_modules tree inside a long working folder can pass that limit, and Explorer's "Extract all" adds a folder level that pushed some handover files past it on the engineer's laptop.
Do both, in an Administrator PowerShell (right-click PowerShell, Run as administrator):
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Forcegit config --system core.longpaths trueThe first prints the new value; the second prints nothing. Restart Windows (or at least sign out and in) so every program sees the change. If you cannot get Administrator rights, use git config --global core.longpaths true (no admin needed) and keep your working folder short, for example C:\kims.
Linux and macOS have no such limit; skip this.
#Check everything
git --version
git config --global --get core.autocrlf
gh auth statusgit --version
git config --global --get core.autocrlf
gh auth statusgit --version
git config --get core.autocrlf
git config --get core.longpaths
(Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem").LongPathsEnabled
gh auth statusYou should see a version, input (Linux and macOS) or true (Windows), on Windows true and 1 for the long path settings, and Logged in to github.com.
#If it goes wrong
| What you see | Cause | Fix |
|---|---|---|
git: command not found / 'git' is not recognized |
Not installed, or the window was open before installing | Install, then open a new window |
remote: Repository not found. on clone |
No access to the private repository, or signed in as the wrong account | gh auth status; ask for access to DayntTech/kims-v2; or clone from the bundle |
Support for password authentication was removed |
Typed your GitHub password | Use gh auth login, or a personal access token |
Filename too long on Windows |
Long paths off | Long paths on Windows |
/bin/sh^M: bad interpreter running a .sh |
The file has CRLF (copied or edited on Windows outside Git) | Check out again from Git; or sed -i 's/\r$//' <file> in Git Bash |
| Many files show as modified right after clone on Windows | Line endings only | Modified files that you did not change |
fatal: detected dubious ownership in repository |
The folder belongs to another user (common in containers and shared drives) | git config --global --add safe.directory <path> |
PowerShell shows git output in red |
git writes progress to stderr | Nothing is wrong; check the last line and $LASTEXITCODE |
#Sources
kims-v2/.gitattributes(branchmain;windows-fixesfor thedeploy/cloudfront/**line)kims-v2/deploy/jenkins/Jenkinsfile.site(carriage returns dropped fromkims-site-env)kims-deploy-info/shared/prerequisites.md,kims-deploy-info/local/00-prerequisites.md(line endings, extraction path length)- https://git-scm.com/downloads
- https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration (core.autocrlf)
- https://git-scm.com/docs/gitattributes
- https://github.com/git-for-windows/git/wiki/Git-cannot-create-a-file-or-directory-with-a-long-path
- https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation
- https://github.com/cli/cli/blob/trunk/docs/install_linux.md
- https://cli.github.com/manual/gh_auth_login
- https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent