Files
orion/docs/development/synology-github-repo.md

150 lines
3.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Source: https://kb.synology.com/tr-tr/DSM/help/Git/git?version=7
---
# Git Server Synology DSM 7
Git is an open-source, distributed version control system that helps you manage programming code, documents, or other files in an organized and efficient manner. It also allows for easy collaboration with multiple groups of people.
---
## 🛠️ Create a Git Repository
1. **Sign in to DSM** using an account with administrative privileges.
2. Go to:
**Control Panel > Terminal & SNMP > Terminal**
→ Enable **SSH service**.
3. Go to:
**Control Panel > Shared Folder**
→ Create a shared folder for Git repositories.
4. On your computer, access Synology NAS via SSH:
```bash
ssh [admin_user]@[NAS_IP_or_hostname] -p [SSH_port]
```
Example:
```bash
ssh myadminuser@192.168.1.2 -p 22
```
5. Change to the shared folder:
```bash
cd /[Volume]/[SharedFolder]/
```
Example:
```bash
cd /volume1/mysharefolder/
```
6. Create a folder for the Git repository:
```bash
mkdir [FolderName]
cd [FolderName]
```
7. Initialize a **bare Git repository**:
```bash
git init --bare
```
Adding new repository on NAS DS223J
> ssh boulaht1@DS223J
> sudo -i
> cd /volume1/git-repos/
> git --bare init my-repo.git
> chown -R git-boulaht1:users my-repo.git
> cd my-repo.git/
---
### ✅ **Steps to Push Local Git Repo to Synology NAS**
1. **Ensure your Synology Git repo is initialized as a bare repo**:
On the NAS (via SSH or File Station), the repo should have been created like this:
```bash
git init --bare /volume1/git-repos/myproject.git
```
2. **On your local machine**, navigate to your existing Git repo:
```bash
cd /path/to/your/local/repo
```
3. **Add the Synology NAS as a remote**:
```bash
git remote add origin ssh://youruser@your-nas-ip:/volume1/git-repos/myproject.git
```
Replace:
- `youruser` with your DSM username
- `your-nas-ip` with the IP address or hostname of your NAS
- `/volume1/git-repos/myproject.git` with the full path to your bare repo
4. **Push your local repo to the NAS**:
```bash
git push -u origin master
```
If error message fatal: detected dubious ownership in repository at '/volume1/git-repos/my-repo.git' - Execute:
> git config --global --add safe.directory /volume1/git-repos/test-repo.git
Go on the Synology and right click on the folder and select Properties
and then Permission and then tick boxes apply to sub folder and files
(git-boulaht1 should be read write on the folder)
> ⚠️ **Note:**
> Do **not** perform the above commands with root permissions.
> Git Server no longer supports `git-shell` commands due to security concerns.
> For `git-shell` access, consider using container-based Git services.
---
## 🔄 Clone Git Repositories from DSM
1. **Install Git** on your computer.
2. Ensure the following:
- SSH service is enabled on DSM.
- Your user account has access permissions to the repository.
- Your user account has **Read/Write** permissions for the shared folder.
3. Clone the repository:
```bash
git clone ssh://[username]@[NAS_IP_or_hostname]:[repository_path]
```
Example:
```bash
git clone ssh://mygituser@192.168.1.2:/volume1/myreposfolder/myrepo1
```
4. Access the cloned repository:
```bash
cd [repository_path]
```
Example:
```bash
cd /volume1/mysharefolder/myrepo1
```
---