127 lines
4.1 KiB
Markdown
127 lines
4.1 KiB
Markdown
---
|
|
sidebar_position: 5
|
|
title: "Git and Repository"
|
|
---
|
|
|
|
# Git and Repository
|
|
|
|
---
|
|
|
|
# Step 7 — Install and Configure Git
|
|
|
|
## 7.1 — Install Git
|
|
|
|
1. Install **Git** if not already installed. [Download from here](https://git-scm.com/download/win).
|
|
2. Run the installer. When prompted for the default editor, choose whichever you are comfortable with (Notepad is fine for occasional use).
|
|
3. On the **"Adjusting your PATH environment"** screen, select **"Git from the command line and also from 3rd-party software"** — this makes Git available in CMD, PowerShell, and Cygwin.
|
|
4. Complete the rest of the installation with default settings.
|
|
5. Verify the installation by opening a **new** terminal and running:
|
|
|
|
```bash
|
|
git --version
|
|
```
|
|
|
|
## 7.2 — Configure Your Identity
|
|
|
|
Git requires a name and email to be set before you can make any commit. These are embedded in every commit you create and must match your Gitea identity.
|
|
|
|
```bash
|
|
git config --global user.name "Your Full Name"
|
|
git config --global user.email "your.email@company.com"
|
|
```
|
|
|
|
> Use the same email address as your Gitea account.
|
|
|
|
## 7.3 — Configure Line Endings
|
|
|
|
This is a **critical setting** for the team. Incorrect line ending configuration causes unnecessary diffs, pollutes commit history, and can break file parsing on the server side.
|
|
|
|
Run the following commands exactly as written:
|
|
|
|
```bash
|
|
git config --global core.autocrlf false
|
|
git config --global core.eol lf
|
|
```
|
|
|
|
| Setting | Value | Reason |
|
|
| --------------- | ------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
| `core.autocrlf` | `false` | Disables automatic line ending conversion. Git will not touch line endings on checkout or commit. |
|
|
| `core.eol` | `lf` | Enforces LF (`\n`) as the line ending for all files in the working tree, consistent with the server and Linux environments. |
|
|
|
|
> ⚠️ **Do not skip this step.** If `autocrlf` is left at its Windows default of `true`, Git will silently convert all line endings to CRLF on checkout and back to LF on commit. This causes every file to appear modified on Windows even when no real changes were made.
|
|
|
|
## 7.4 — Configure Default Branch Name
|
|
|
|
The team uses `master` as the default branch name. Set this to avoid a mismatch when creating new local branches:
|
|
|
|
```bash
|
|
git config --global init.defaultBranch master
|
|
```
|
|
|
|
## 7.5 — Verify Your Configuration
|
|
|
|
Run the following to confirm all settings were applied correctly:
|
|
|
|
```bash
|
|
git config --global --list
|
|
```
|
|
|
|
You should see at minimum:
|
|
|
|
```bash
|
|
user.name=Your Full Name
|
|
user.email=your.email@company.com
|
|
core.autocrlf=false
|
|
core.eol=lf
|
|
init.defaultbranch=master
|
|
```
|
|
|
|
---
|
|
|
|
# Step 8 — Clone the Project Repository
|
|
|
|
1. Open a terminal and clone the Stock repository:
|
|
|
|
```bash
|
|
git clone http://145.239.66.197:3000/TrizTech/TrizStockRepository.git
|
|
```
|
|
|
|
2. When prompted, enter your Gitea username and password (or token if your Gitea instance requires it).
|
|
3. Navigate into the project folder:
|
|
|
|
```bash
|
|
cd TrizStockRepository
|
|
```
|
|
|
|
---
|
|
|
|
# Step 9 — Configure `database.properties`
|
|
|
|
The `database.properties` file contains the local database connection settings. It is **never stored in the repository** for security reasons. You need to create it manually.
|
|
|
|
1. Download the template from the [team resources repository](http://145.239.66.197:3000/othmane/team-resources/src/branch/main/uses/stock).
|
|
2. Copy the template into the correct location inside your local repository:
|
|
|
|
```text
|
|
\src\main\resources\database.properties
|
|
```
|
|
|
|
3. Open the file in any text editor and fill in your local values:
|
|
|
|
```properties
|
|
db.host=localhost
|
|
db.port=1433
|
|
db.name=TrizStockLife
|
|
db.username=YOUR_DB_USERNAME
|
|
db.password=YOUR_DB_PASSWORD
|
|
```
|
|
|
|
4. Verify that `database.properties` is listed in the project's `.gitignore`:
|
|
|
|
```text
|
|
# In the project root, open .gitignore and confirm this line exists:
|
|
database.properties
|
|
```
|
|
|
|
If it is not there, add it. **Never commit this file.**
|