Files
dotfiles/nixos/docs/05-git-config.md
T
Dmitry 17b0cdfbac feat: add comprehensive NixOS configuration documentation and structure
- Introduced `08-structure.md` detailing project structure, main files, and versioning.
- Created `README.md` for documentation overview and quick start guide.
- Added user-specific configurations for Alacritty, Vim, Micro, Git, Zsh, Tmux, and tools.
- Implemented system modules for desktop environment (KDE Plasma), audio (PipeWire), networking, and services (OpenSSH, GnuPG).
- Configured Nix settings with flakes support and garbage collection.
- Established user management for `ada` with necessary groups and shell settings.
- Enabled VirtualBox guest additions for improved VM experience.
2026-03-10 13:10:52 +03:00

229 lines
4.0 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.
# Git конфигурация
Как настроить Git алиасы и конфигурацию.
## Где Git конфиг?
Git конфигурация находится в:
```
home/ada/git.nix
```
## Пользователь
```nix
programs.git = {
enable = true;
userName = "Dmitry";
userEmail = "ada.dmitry@gmail.com";
```
Изменить имя и email:
```nix
userName = "Твоё имя";
userEmail = "твой@email.com";
```
## Добавить alias
Алиасы находятся в `aliases`:
```nix
aliases = {
# Базовые
st = "status";
co = "checkout";
br = "branch";
# Твой новый alias:
quick-commit = "commit -am";
};
```
### Примеры полезных алиасов
```nix
# Быстрая работа с коммитами
cm = "commit -m";
amend = "commit --amend";
undo = "reset --soft HEAD^";
# Логи
lg = "log --graph --oneline --all";
recent = "log -10 --oneline";
# Ветки
new-branch = "checkout -b";
sync = "pull --rebase";
# Простые проверки
changed = "diff --name-only";
staged = "diff --cached";
```
## Глобальный gitignore
Файлы которые всегда игнорируются:
```nix
ignores = [
".DS_Store" # macOS
"Thumbs.db" # Windows
".vscode/" # VS Code
".idea/" # IntelliJ
"*.swp" # Vim
# Добавить свой:
".myfile"
];
```
## Цвета
Визуальная конфигурация разных элементов:
```nix
"color \"branch\"" = {
current = "yellow bold";
local = "green";
remote = "cyan";
};
"color \"diff\"" = {
meta = "yellow";
old = "red bold";
new = "green bold";
};
```
Можешь изменять цвета на свой вкус.
## Основные настройки
```nix
extraConfig = {
# Ветка по умолчанию
init.defaultBranch = "main";
# Автоматический rebase при pull
pull.rebase = true;
# Редактор для коммитов
core.editor = "micro";
};
```
## Проверка конфигурации
После изменений собери конфигурацию:
```bash
nh os switch
```
Проверить что применилось:
```bash
git config --list | grep user
git config user.name
git alias # Если есть такой alias
```
## Использование алиасов
```bash
# Вместо:
git status
# Используешь:
g st # Если есть alias g = git
```
## Работа с удалёнными репозиториями
Если нужны специальные алиасы для pull/push:
```nix
# В алиасах:
pom = "push origin main";
plm = "pull origin main";
```
## Слияние веток
```nix
# Алиасы для слияния
merge-main = "merge main";
merge-dev = "merge develop";
```
## Интерактивные операции
Хорошие алиасы для интерактивной работы:
```nix
interactive = "rebase -i";
fixup = "rebase -i --autosquash";
```
## Проверка перед применением
```bash
# Посмотреть текущие алиасы
git config --get-regexp alias
# Проверить синтаксис после редактирования
nix flake check
```
## Git UI
Если хочешь использовать интерактивный Git UI:
```bash
lazygit # Уже установлен в пакетах
```
## Частые операции
### Быстрый коммит
```nix
# Добавить алиас
quick = "commit -am";
```
```bash
git quick "commit message"
```
### История файла
```nix
# Алиас
history = "log --oneline";
```
```bash
git history <file>
```
### Визуальное дерево
```bash
# Уже есть
git lg # или git l
```
## Если что-то сломалось
Вернуть конфиг по умолчанию:
```bash
# Отменить последние изменения
git checkout home/ada/git.nix
# Пересобрать
nh os switch
```