Add Git setup instructions for root user
- Add comprehensive guide for Git configuration under root user - Include SSH key setup, Personal Access Token, and credential management - Add troubleshooting section for common Git issues - Document current Git configuration status
This commit is contained in:
+148
@@ -0,0 +1,148 @@
|
||||
# Настройка Git для работы под пользователем root
|
||||
|
||||
## Текущая конфигурация
|
||||
|
||||
Git уже настроен для работы под пользователем root:
|
||||
|
||||
```bash
|
||||
git config --global user.name "root"
|
||||
git config --global user.email "root@localhost"
|
||||
```
|
||||
|
||||
## Настройка аутентификации для GitLab
|
||||
|
||||
### Вариант 1: SSH ключи (рекомендуется)
|
||||
|
||||
1. **Проверьте существующие SSH ключи:**
|
||||
```bash
|
||||
ls -la ~/.ssh/
|
||||
```
|
||||
|
||||
2. **Если ключей нет, создайте новый:**
|
||||
```bash
|
||||
ssh-keygen -t ed25519 -C "root@localhost"
|
||||
```
|
||||
|
||||
3. **Добавьте публичный ключ в GitLab:**
|
||||
```bash
|
||||
cat ~/.ssh/id_ed25519.pub
|
||||
```
|
||||
Скопируйте содержимое и добавьте в GitLab: Settings → SSH Keys
|
||||
|
||||
4. **Настройте SSH для GitLab:**
|
||||
```bash
|
||||
# Добавьте в ~/.ssh/config
|
||||
Host gitlab.konturai.kz
|
||||
HostName gitlab.konturai.kz
|
||||
User git
|
||||
IdentityFile ~/.ssh/id_ed25519
|
||||
```
|
||||
|
||||
5. **Измените URL репозитория на SSH:**
|
||||
```bash
|
||||
git remote set-url origin git@gitlab.konturai.kz:web/marketing.git
|
||||
```
|
||||
|
||||
### Вариант 2: Personal Access Token
|
||||
|
||||
1. **Создайте Personal Access Token в GitLab:**
|
||||
- Перейдите в GitLab: User Settings → Access Tokens
|
||||
- Создайте токен с правами: `read_repository`, `write_repository`
|
||||
|
||||
2. **Используйте токен для аутентификации:**
|
||||
```bash
|
||||
# При push Git запросит логин и пароль
|
||||
# Логин: ваш_username
|
||||
# Пароль: personal_access_token
|
||||
git push origin main
|
||||
```
|
||||
|
||||
3. **Или настройте credential helper:**
|
||||
```bash
|
||||
git config --global credential.helper store
|
||||
```
|
||||
|
||||
### Вариант 3: Настройка через переменные окружения
|
||||
|
||||
```bash
|
||||
# Добавьте в ~/.bashrc или ~/.zshrc
|
||||
export GIT_AUTHOR_NAME="root"
|
||||
export GIT_AUTHOR_EMAIL="root@localhost"
|
||||
export GIT_COMMITTER_NAME="root"
|
||||
export GIT_COMMITTER_EMAIL="root@localhost"
|
||||
```
|
||||
|
||||
## Команды для работы с Git
|
||||
|
||||
### Основные команды
|
||||
```bash
|
||||
# Проверить статус
|
||||
git status
|
||||
|
||||
# Добавить файлы
|
||||
git add .
|
||||
|
||||
# Создать коммит
|
||||
git commit -m "Commit message"
|
||||
|
||||
# Отправить изменения
|
||||
git push origin main
|
||||
|
||||
# Получить изменения
|
||||
git pull origin main
|
||||
```
|
||||
|
||||
### Работа с Docker файлами
|
||||
```bash
|
||||
# Добавить Docker файлы
|
||||
git add Dockerfile docker-compose.yml nginx.conf .dockerignore DOCKER.md
|
||||
|
||||
# Создать коммит
|
||||
git commit -m "Add Docker configuration"
|
||||
|
||||
# Отправить в репозиторий
|
||||
git push origin main
|
||||
```
|
||||
|
||||
## Проверка конфигурации
|
||||
|
||||
```bash
|
||||
# Проверить текущую конфигурацию
|
||||
git config --global --list
|
||||
|
||||
# Проверить удаленные репозитории
|
||||
git remote -v
|
||||
|
||||
# Проверить SSH подключение
|
||||
ssh -T git@gitlab.konturai.kz
|
||||
```
|
||||
|
||||
## Решение проблем
|
||||
|
||||
### Проблема: Permission denied
|
||||
```bash
|
||||
# Проверить права доступа к SSH ключам
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
chmod 644 ~/.ssh/id_ed25519.pub
|
||||
```
|
||||
|
||||
### Проблема: Authentication failed
|
||||
```bash
|
||||
# Очистить кэш credentials
|
||||
git config --global --unset credential.helper
|
||||
git config --global credential.helper store
|
||||
```
|
||||
|
||||
### Проблема: SSL certificate
|
||||
```bash
|
||||
# Отключить проверку SSL (не рекомендуется для продакшена)
|
||||
git config --global http.sslVerify false
|
||||
```
|
||||
|
||||
## Текущий статус
|
||||
|
||||
- ✅ Git настроен под пользователя root
|
||||
- ✅ Docker файлы созданы и добавлены в репозиторий
|
||||
- ⚠️ Требуется настройка аутентификации для push в GitLab
|
||||
|
||||
Для завершения настройки выберите один из вариантов аутентификации выше.
|
||||
Reference in New Issue
Block a user