372 lines
No EOL
12 KiB
Markdown
372 lines
No EOL
12 KiB
Markdown
# Installing Git
|
||
The following are the steps in install Git on either [Linux](#linux), [Windows](#windows) or [Mac](#mac).
|
||
|
||
|
||
|
||
*These steps were created using ChatGPT, so there might be some errors.*
|
||
<br>
|
||
*If you run into errors, or if there's any missteps please log an issue here:*
|
||
<br>
|
||
*https://hub.openingdesign.com/OpeningDesign/Bonsai_Tutorials/issues*
|
||
<br>
|
||
*or create a pull request with the change. Thank you.*
|
||
|
||
|
||
|
||
<br>
|
||
|
||
# Linux
|
||
|
||
|
||
### **1. Check if Git is Already Installed**
|
||
|
||
Before installing, check if Git is already installed by running:
|
||
[*How to open the terminal*](Open%20Command%20Prompt%20or%20Git%20Bash.md#linux)
|
||
|
||
|
||
`git --version`
|
||
|
||
If Git is installed, it will display the version. If not, follow the steps below.
|
||
|
||
----------
|
||
|
||
### **2. Install Git Based on Your Linux Distribution**
|
||
|
||
#### **Debian/Ubuntu-based distributions (e.g., Ubuntu, Linux Mint, Pop!_OS)**
|
||
|
||
|
||
|
||
`sudo apt update
|
||
sudo apt install git -y`
|
||
|
||
#### **Fedora**
|
||
|
||
|
||
`sudo dnf install git -y`
|
||
|
||
#### **Arch Linux/Manjaro**
|
||
|
||
|
||
`sudo pacman -S git`
|
||
|
||
#### **openSUSE**
|
||
|
||
|
||
`sudo zypper install git`
|
||
|
||
#### **RHEL/CentOS (8 and later)**
|
||
|
||
|
||
`sudo dnf install git -y`
|
||
|
||
For CentOS 7 (uses `yum` instead of `dnf`):
|
||
|
||
|
||
`sudo yum install git -y`
|
||
|
||
----------
|
||
|
||
### **3. Verify Installation**
|
||
|
||
After installation, confirm that Git is installed by running:
|
||
|
||
|
||
`git --version`
|
||
|
||
You should see output like:
|
||
|
||
|
||
`git version 2.x.x`
|
||
|
||
----------
|
||
|
||
### **4. Set Up Git (First-Time Configuration)**
|
||
|
||
1. After installing, configure your Git identity:
|
||
- `git config --global user.name "Your Name"`
|
||
- `git config --global user.email "your.email@example.com"`
|
||
2. To check your configuration:
|
||
- `git config --list`
|
||
3. Add [these](#git-settings-for-windows-mac-linux) settings. The repo is large, so the following settings prevent cloning errors.
|
||
|
||
|
||
Git is now installed and ready to use! 🚀
|
||
|
||
<br>
|
||
|
||
---
|
||
|
||
# Windows
|
||
|
||
### 1. **Download Git for Windows**
|
||
|
||
- Go to the official Git website: [https://git-scm.com/downloads](https://git-scm.com/downloads)
|
||
- Click on **Windows** to download the latest Git installer.
|
||
|
||
### 2. **Run the Installer**
|
||
|
||
- Locate the downloaded `.exe` file (e.g., `Git-2.x.x-64-bit.exe`) and double-click it.
|
||
|
||
### 3. **Follow Installation Steps**
|
||
- The following are most likely default settings during installation. If unsure, go with the prompted defaults.
|
||
- **Select Destination** → Choose where Git will be installed (default is fine).
|
||
- **Choose Components** → Keep the defaults unless you have specific needs.
|
||
- **Select Default Editor** → Choose an editor for Git (default is Vim, but you can select Notepad++, VS Code, etc.).
|
||
- **Adjust Path Environment** → Choose:
|
||
- **"Git from the command line and also from 3rd-party software"** (Recommended)
|
||
- **Choose HTTPS Backend** → Use the default "Use the OpenSSL library."
|
||
- **Choose Line Ending Conversion** → Select:
|
||
- **"Checkout Windows-style, commit Unix-style line endings"** (Recommended)
|
||
- **Configure Terminal Emulator** → Choose:
|
||
- **"Use MinTTY"** (default) or **Windows Console Window** (if you prefer `cmd`).
|
||
- **Default Behavior for `git pull`** → Choose:
|
||
- **"Default (fast-forward or merge)"** (unless you prefer rebase).
|
||
- **Enable Experimental Features** → Optional.
|
||
|
||
### 4. **Finish and Verify Installation**
|
||
|
||
- Click **Install**, then **Finish** once done.
|
||
- Open **Command Prompt** or **Git Bash** and type:
|
||
[*How to open the terminal*](Open%20Command%20Prompt%20or%20Git%20Bash.md#windows)
|
||
|
||
|
||
`git --version`
|
||
|
||
If Git is installed correctly, it will return the installed version.
|
||
|
||
### 5. **Set Up Git (First-Time Configuration)**
|
||
|
||
1. After installing, configure your Git identity:
|
||
- `git config --global user.name "Your Name"`
|
||
- `git config --global user.email "your.email@example.com"`
|
||
2. To check your configuration:
|
||
- `git config --list`
|
||
3. Add [these](#git-settings-for-windows-mac-linux) settings. The repo is large, so the following settings prevent cloning errors.
|
||
|
||
|
||
|
||
Now, Git is installed and ready to use on Windows! 🚀
|
||
<br>
|
||
|
||
---
|
||
|
||
# Mac
|
||
|
||
You can install Git on macOS using several methods. Here are the most common ones:
|
||
|
||
|
||
### **1. Check if Git is Already Installed**
|
||
|
||
Before installing, check if Git is already available by running:
|
||
[*How to open the terminal*](Open%20Command%20Prompt%20or%20Git%20Bash.md#max)
|
||
|
||
|
||
`git --version`
|
||
|
||
|
||
If Git is installed, it will display the version. If not, proceed with one of the installation methods below.
|
||
|
||
----------
|
||
|
||
### **2. Install Git Using Homebrew (Recommended)**
|
||
|
||
Homebrew is a package manager for macOS that makes installing Git easy.
|
||
|
||
#### **Step 1: Install Homebrew (if not already installed)**
|
||
|
||
If you don’t have Homebrew, install it by running:
|
||
|
||
|
||
`/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`
|
||
|
||
#### **Step 2: Install Git**
|
||
|
||
Once Homebrew is installed, install Git with:
|
||
|
||
|
||
`brew install git`
|
||
|
||
#### **Step 3: Verify Installation**
|
||
|
||
After installation, check the Git version:
|
||
|
||
|
||
`git --version`
|
||
|
||
----------
|
||
|
||
### **3. Install Git via Xcode Command Line Tools (Alternative)**
|
||
|
||
macOS includes a lightweight version of Git with Xcode’s command-line tools.
|
||
|
||
#### **Step 1: Run the Installation Command**
|
||
|
||
|
||
`xcode-select --install`
|
||
|
||
#### **Step 2: Follow the On-Screen Prompts**
|
||
|
||
- A pop-up will appear asking if you want to install the tools. Click **"Install"**.
|
||
- Wait for the installation to complete.
|
||
|
||
#### **Step 3: Verify Installation**
|
||
|
||
|
||
`git --version`
|
||
|
||
----------
|
||
|
||
### **4. Install Git via the Official Git Installer**
|
||
|
||
If you prefer, you can download Git directly from the official site.
|
||
|
||
#### **Step 1: Download Git for macOS**
|
||
|
||
Go to [https://git-scm.com/download/mac](https://git-scm.com/download/mac) and download the latest `.dmg` installer.
|
||
|
||
#### **Step 2: Install Git**
|
||
|
||
- Open the `.dmg` file and follow the installation steps.
|
||
- After installation, restart your terminal and verify Git is installed using:
|
||
|
||
|
||
`git --version`
|
||
|
||
|
||
----------
|
||
|
||
### **5. Set Up Git (First-Time Configuration)**
|
||
|
||
1. After installing, configure your Git identity:
|
||
- `git config --global user.name "Your Name"`
|
||
- `git config --global user.email "your.email@example.com"`
|
||
2. To check your configuration:
|
||
- `git config --list`
|
||
3. Add [these](#git-settings-for-windows-mac-linux) settings. The repo is large, so the following settings prevent cloning errors.
|
||
|
||
|
||
Now, Git is installed and ready to use on your Mac! 🚀
|
||
|
||
|
||
---
|
||
|
||
# Git Settings For Windows/Mac/Linux
|
||
|
||
These are important as some of the videos have long names, and this will trigger an error when cloning the repo. [Run]((Open%20Command%20Prompt%20or%20Git%20Bash.md)) the following commands from your command line
|
||
|
||
*important: open the command line [as the administrator](Open%20Command%20Prompt%20or%20Git%20Bash.md).*
|
||
|
||
1. `git config --system core.longpaths true`
|
||
<!-- - Long answer [here](https://stackoverflow.com/questions/22575662/filename-too-long-in-git-for-windows/22575737#22575737) -->
|
||
2. `git config --system --unset core.autocrlf`
|
||
3. `git config --global core.autocrlf true`
|
||
4. `git config --global core.compression 0`
|
||
<!-- - Long answer [here](https://stackoverflow.com/a/22317479) -->
|
||
5. `git config --global http.postBuffer 1048576000`
|
||
<!-- - Long answer [here](https://stackoverflow.com/a/6849424/414643) -->
|
||
6. If on Windows add the following settings, as well.
|
||
- Tell Windows to enable long file paths system-wide
|
||
- 2 options
|
||
- If CMD or Powershell:
|
||
- `reg add HKLM\SYSTEM\CurrentControlSet\Control\FileSystem /v LongPathsEnabled /t REG_DWORD /d 1 /f`
|
||
- If Git Bash:
|
||
- `cmd.exe /c "reg add HKLM\SYSTEM\CurrentControlSet\Control\FileSystem /v LongPathsEnabled /t REG_DWORD /d 1 /f"`
|
||
- To manually verify.
|
||
- Go to start menu and type 'regedit'
|
||
- Navigate to `Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem`
|
||
- Right click on `LongPathsEnabled`. It should read as the following value, if not, change it to `1`.
|
||
- Value data = `1`
|
||
|
||
|
||
# Troubleshooting if repo "hangs" while cloning
|
||
|
||
|
||
When cloning, if the repo 'hangs' or doesn't download fully, the following are a few things worth trying, roughly in order of which one will most likely fix the problem.
|
||
|
||
1. **Increase the HTTP post buffer and Disable compression** (most common fix). *These settings were mentioned in [the settings](#git-settings-for-windows-mac-linux) section above. We recommend setting all those listed there*:
|
||
- *As mentioned above, open the command line [as the administrator](Open%20Command%20Prompt%20or%20Git%20Bash.md).*
|
||
|
||
|
||
```bash
|
||
git config --global http.postBuffer 1048576000
|
||
git config --global http.compression 0
|
||
```
|
||
Then retry the clone.
|
||
|
||
|
||
2. **Try a shallow clone first** to see if the repo itself clones at all:
|
||
|
||
|
||
```bash
|
||
git clone --recursive --depth 1 https://hub.openingdesign.com/OpeningDesign/Bonsai_Tutorials.git
|
||
```
|
||
|
||
3. **Clone without `--recursive`** first, then init submodules separately — this isolates whether the problem is the main repo or a submodule:
|
||
|
||
|
||
```bash
|
||
git clone https://hub.openingdesign.com/OpeningDesign/Bonsai_Tutorials.git
|
||
cd Bonsai_Tutorials
|
||
git submodule update --init --recursive
|
||
```
|
||
|
||
4. **Use SSH instead of HTTPS** — SSH avoids the HTTP chunked transfer issue entirely.
|
||
```bash
|
||
git clone git@hub.openingdesign.com:OpeningDesign/Bonsai_Tutorials.git
|
||
```
|
||
|
||
|
||
|
||
<!--
|
||
|
||
```
|
||
7. Just to make sure you got it right, copy the following into Powershell...
|
||
|
||
Write-Output "=== Git Settings ==="
|
||
Write-Output "core.longpaths (system): $(git config --system --get core.longpaths)"
|
||
Write-Output "core.autocrlf (system): $(git config --system --get core.autocrlf)"
|
||
Write-Output "core.autocrlf (global): $(git config --global --get core.autocrlf)"
|
||
Write-Output "core.autocrlf (local): $(git config --local --get core.autocrlf)"
|
||
Write-Output "core.compression (global): $(git config --global --get core.compression)"
|
||
Write-Output "http.postBuffer (global): $(git config --global --get http.postBuffer)"
|
||
|
||
Write-Output "`n=== Windows Registry ==="
|
||
$lp = Get-ItemPropertyValue -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -ErrorAction SilentlyContinue
|
||
if ($null -eq $lp) {
|
||
Write-Output "LongPathsEnabled: (not set)"
|
||
} else {
|
||
Write-Output "LongPathsEnabled: $lp"
|
||
}
|
||
|
||
```
|
||
You should get a print out like this...
|
||
```
|
||
PS D:\Dropbox\Gitea_OD\Bonsai_Tutorials> Write-Output "=== Git Settings ==="
|
||
=== Git Settings ===
|
||
PS D:\Dropbox\Gitea_OD\Bonsai_Tutorials> Write-Output "core.longpaths (system): $(git config --system --get core.longpaths)"
|
||
core.longpaths (system): true
|
||
PS D:\Dropbox\Gitea_OD\Bonsai_Tutorials> Write-Output "core.autocrlf (system): $(git config --system --get core.autocrlf)"
|
||
core.autocrlf (system):
|
||
PS D:\Dropbox\Gitea_OD\Bonsai_Tutorials> Write-Output "core.autocrlf (global): $(git config --global --get core.autocrlf)"
|
||
core.autocrlf (global): true
|
||
PS D:\Dropbox\Gitea_OD\Bonsai_Tutorials> Write-Output "core.autocrlf (local): $(git config --local --get core.autocrlf)"
|
||
core.autocrlf (local):
|
||
PS D:\Dropbox\Gitea_OD\Bonsai_Tutorials> Write-Output "core.compression (global): $(git config --global --get core.compression)"
|
||
core.compression (global): 0
|
||
PS D:\Dropbox\Gitea_OD\Bonsai_Tutorials> Write-Output "http.postBuffer (global): $(git config --global --get http.postBuffer)"
|
||
http.postBuffer (global): 1048576000
|
||
PS D:\Dropbox\Gitea_OD\Bonsai_Tutorials>
|
||
PS D:\Dropbox\Gitea_OD\Bonsai_Tutorials> Write-Output "`n=== Windows Registry ==="
|
||
|
||
=== Windows Registry ===
|
||
PS D:\Dropbox\Gitea_OD\Bonsai_Tutorials> $lp = Get-ItemPropertyValue -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -ErrorAction SilentlyContinue
|
||
PS D:\Dropbox\Gitea_OD\Bonsai_Tutorials> if ($null -eq $lp) {
|
||
>> Write-Output "LongPathsEnabled: (not set)"
|
||
>> } else {
|
||
>> Write-Output "LongPathsEnabled: $lp"
|
||
>> }
|
||
LongPathsEnabled: 1
|
||
PS D:\Dropbox\Gitea_OD\Bonsai_Tutorials>
|
||
```
|
||
|
||
--> |