git-ssh-sync 0.2.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {git_ssh_sync-0.2.0 → git_ssh_sync-0.4.0}/PKG-INFO +281 -2
- {git_ssh_sync-0.2.0 → git_ssh_sync-0.4.0}/README.md +280 -1
- {git_ssh_sync-0.2.0 → git_ssh_sync-0.4.0}/pyproject.toml +1 -1
- {git_ssh_sync-0.2.0 → git_ssh_sync-0.4.0}/src/git_ssh_sync/__init__.py +1 -1
- git_ssh_sync-0.4.0/src/git_ssh_sync/attach.py +487 -0
- {git_ssh_sync-0.2.0 → git_ssh_sync-0.4.0}/src/git_ssh_sync/branch.py +8 -1
- {git_ssh_sync-0.2.0 → git_ssh_sync-0.4.0}/src/git_ssh_sync/cli.py +214 -7
- git_ssh_sync-0.4.0/src/git_ssh_sync/clone.py +171 -0
- {git_ssh_sync-0.2.0 → git_ssh_sync-0.4.0}/src/git_ssh_sync/config.py +53 -6
- git_ssh_sync-0.4.0/src/git_ssh_sync/dev.py +110 -0
- {git_ssh_sync-0.2.0 → git_ssh_sync-0.4.0}/src/git_ssh_sync/doctor.py +293 -48
- {git_ssh_sync-0.2.0 → git_ssh_sync-0.4.0}/src/git_ssh_sync/git.py +16 -0
- git_ssh_sync-0.4.0/src/git_ssh_sync/logging_config.py +84 -0
- git_ssh_sync-0.4.0/src/git_ssh_sync/ssh.py +295 -0
- {git_ssh_sync-0.2.0 → git_ssh_sync-0.4.0}/src/git_ssh_sync/status.py +41 -15
- {git_ssh_sync-0.2.0 → git_ssh_sync-0.4.0}/src/git_ssh_sync/sync.py +166 -8
- git_ssh_sync-0.4.0/src/git_ssh_sync/windows_git_ssh.py +52 -0
- git_ssh_sync-0.2.0/src/git_ssh_sync/clone.py +0 -92
- git_ssh_sync-0.2.0/src/git_ssh_sync/ssh.py +0 -55
- {git_ssh_sync-0.2.0 → git_ssh_sync-0.4.0}/src/git_ssh_sync/console.py +0 -0
- {git_ssh_sync-0.2.0 → git_ssh_sync-0.4.0}/src/git_ssh_sync/errors.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: git-ssh-sync
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Sync Git commits through a local machine for development environments without direct GitHub or GitLab access.
|
|
5
5
|
Requires-Dist: pydantic>=2.13.4
|
|
6
6
|
Requires-Dist: pyyaml>=6.0.3
|
|
@@ -90,8 +90,32 @@ Key parameters:
|
|
|
90
90
|
- `--origin`: Repository URL on the GitHub / GitLab side
|
|
91
91
|
- `--dev-host`: SSH host of the development environment
|
|
92
92
|
- `--dev-user`: SSH user of the development environment
|
|
93
|
+
- `--dev-os`: Development environment OS, either `posix` or `windows` (default: `posix`)
|
|
93
94
|
- `--dev-path`: Path to the work repository on the development environment
|
|
94
95
|
|
|
96
|
+
For a Windows development environment, specify `--dev-os windows` and use Windows
|
|
97
|
+
paths. Windows SSH commands are executed through PowerShell.
|
|
98
|
+
|
|
99
|
+
```powershell
|
|
100
|
+
git-ssh-sync init myproject `
|
|
101
|
+
--origin git@github.com:example/myproject.git `
|
|
102
|
+
--dev-host devserver `
|
|
103
|
+
--dev-user user `
|
|
104
|
+
--dev-os windows `
|
|
105
|
+
--dev-path 'C:\Users\user\work\myproject'
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
When running the command from macOS or Linux shells such as `zsh` or `bash`,
|
|
109
|
+
quote Windows paths that contain backslashes. Otherwise the shell can remove the
|
|
110
|
+
backslashes before `git-ssh-sync` receives the argument. You can also use forward
|
|
111
|
+
slashes, for example `C:/Users/user/work/myproject`.
|
|
112
|
+
|
|
113
|
+
When `--dev-os windows` is used, the default cache path is
|
|
114
|
+
`C:\Users\<dev-user>\.git-ssh-sync\cache\<project>.git`. `clone` stops if either
|
|
115
|
+
the configured work path or cache path already exists on the development
|
|
116
|
+
environment, so remove stale directories or use the attach/recover workflow for
|
|
117
|
+
existing repositories.
|
|
118
|
+
|
|
95
119
|
For `--origin`, specify a remote URL that can be used with `git clone` or `git fetch`. Main formats are:
|
|
96
120
|
|
|
97
121
|
```text
|
|
@@ -115,6 +139,59 @@ git-ssh-sync init myproject \
|
|
|
115
139
|
--force
|
|
116
140
|
```
|
|
117
141
|
|
|
142
|
+
### Configuration file
|
|
143
|
+
|
|
144
|
+
Project settings are saved as YAML. The default path depends on the local
|
|
145
|
+
machine where `git-ssh-sync` runs:
|
|
146
|
+
|
|
147
|
+
```text
|
|
148
|
+
macOS / Linux: ~/.config/git-ssh-sync/config.yaml
|
|
149
|
+
Windows: %APPDATA%\git-ssh-sync\config.yaml
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
A generated configuration looks like this:
|
|
153
|
+
|
|
154
|
+
```yaml
|
|
155
|
+
version: 1
|
|
156
|
+
|
|
157
|
+
projects:
|
|
158
|
+
myproject:
|
|
159
|
+
origin: git@github.com:example/myproject.git
|
|
160
|
+
|
|
161
|
+
local:
|
|
162
|
+
repo_path: ~/.git-ssh-sync/repos/myproject
|
|
163
|
+
|
|
164
|
+
dev:
|
|
165
|
+
host: devserver
|
|
166
|
+
user: user
|
|
167
|
+
os: posix
|
|
168
|
+
work_path: /home/user/work/myproject
|
|
169
|
+
cache_path: /home/user/.git-ssh-sync/cache/myproject.git
|
|
170
|
+
|
|
171
|
+
options:
|
|
172
|
+
sync_tags: true
|
|
173
|
+
lfs: false
|
|
174
|
+
submodules: false
|
|
175
|
+
ff_only: true
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Main fields:
|
|
179
|
+
|
|
180
|
+
- `origin`: GitHub / GitLab repository URL used by the local gateway repository
|
|
181
|
+
- `local.repo_path`: Local gateway repository path managed by `git-ssh-sync`
|
|
182
|
+
- `dev.host`, `dev.user`, `dev.os`: SSH connection target and remote OS
|
|
183
|
+
- `dev.work_path`: Work repository path on the development environment
|
|
184
|
+
- `dev.cache_path`: Bare cache repository path on the development environment
|
|
185
|
+
- `options.sync_tags`: Synchronize Git tags when pulling or pushing
|
|
186
|
+
- `options.lfs`: Reserved option for Git LFS support
|
|
187
|
+
- `options.submodules`: Reserved option for submodule support
|
|
188
|
+
- `options.ff_only`: Keep synchronization fast-forward only
|
|
189
|
+
|
|
190
|
+
In normal use, manage this file with `git-ssh-sync init` and
|
|
191
|
+
`git-ssh-sync config` commands. If you edit it manually, keep the YAML
|
|
192
|
+
structure unchanged and use paths that are valid on the machine or
|
|
193
|
+
development environment where each field is used.
|
|
194
|
+
|
|
118
195
|
You can inspect and maintain registered projects without opening the config file directly.
|
|
119
196
|
|
|
120
197
|
```bash
|
|
@@ -128,6 +205,7 @@ git-ssh-sync config show myproject
|
|
|
128
205
|
git-ssh-sync config set myproject \
|
|
129
206
|
--origin git@github.com:example/myproject.git \
|
|
130
207
|
--dev-host devserver \
|
|
208
|
+
--dev-os posix \
|
|
131
209
|
--dev-path /home/user/work/myproject
|
|
132
210
|
|
|
133
211
|
# Remove a project after confirmation
|
|
@@ -161,6 +239,54 @@ Afterward, the work repository on the development environment can be used as a n
|
|
|
161
239
|
|
|
162
240
|
`doctor` checks the local environment, SSH connection, fetch/push permissions to origin, and repository deployment on the development environment. Run this not only for the first time but also when synchronization is not working properly.
|
|
163
241
|
|
|
242
|
+
## Attaching Existing Repositories
|
|
243
|
+
|
|
244
|
+
If the gateway repository, development work repository, or cache repository already
|
|
245
|
+
exists, use `attach` instead of `clone`.
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
git-ssh-sync init myproject \
|
|
249
|
+
--origin git@github.com:example/myproject.git \
|
|
250
|
+
--dev-host devserver \
|
|
251
|
+
--dev-user user \
|
|
252
|
+
--dev-path /home/user/work/myproject
|
|
253
|
+
git-ssh-sync attach myproject --dry-run
|
|
254
|
+
git-ssh-sync attach myproject
|
|
255
|
+
git-ssh-sync doctor myproject
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
`attach` inspects the configured origin URL, current branch, development work
|
|
259
|
+
tree state, bare cache repository, and `gitsync` remote. Before changing
|
|
260
|
+
anything, it prints the operations it will apply. Use `--yes` for non-interactive
|
|
261
|
+
execution after reviewing the plan.
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
git-ssh-sync attach myproject --yes
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
If only the `gitsync` remote or cache wiring is missing or mismatched, run
|
|
268
|
+
`doctor --repair` to inspect and repair it through the same preflight checks.
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
git-ssh-sync doctor myproject --repair
|
|
272
|
+
git-ssh-sync doctor myproject --repair --yes
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
After an interrupted `pull` or `push`, use `recover` as the recovery-oriented
|
|
276
|
+
entry point. Without `--yes`, it diagnoses origin, gateway, cache, and work
|
|
277
|
+
repository state and prints concrete next actions. With `--yes`, it applies only
|
|
278
|
+
safe wiring repairs such as creating the cache repository, seeding the cache
|
|
279
|
+
branch, or fixing the `gitsync` remote.
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
git-ssh-sync recover myproject
|
|
283
|
+
git-ssh-sync recover myproject --yes
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
`attach` and `doctor --repair` do not commit, stash, merge, or rebase existing
|
|
287
|
+
work. If the development work tree is dirty, or if a path is not a compatible Git
|
|
288
|
+
repository, the command stops and prints the manual recovery action.
|
|
289
|
+
|
|
164
290
|
## Daily Development Workflow
|
|
165
291
|
|
|
166
292
|
For daily development, `pull` from the local machine before starting work, commit normally in the development environment, and finally `push` from the local machine.
|
|
@@ -188,6 +314,79 @@ git-ssh-sync push myproject
|
|
|
188
314
|
|
|
189
315
|
`pull` and `push` target the current branch of the work repository on the development environment. To synchronize a different branch, switch the work repository branch with `checkout` first.
|
|
190
316
|
|
|
317
|
+
If you are not sure about the current state at the beginning of work, first check synchronization status from the local machine and run `pull` when needed.
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
git-ssh-sync status myproject
|
|
321
|
+
git-ssh-sync pull myproject
|
|
322
|
+
git-ssh-sync dev status myproject
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
If `dev status` shows a dirty working tree on the development environment, uncommitted changes are not synchronized. Inspect the diff on the development environment and commit the changes you want to synchronize before `push`.
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
git-ssh-sync dev diff myproject --stat
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
Before pushing, confirm that the development environment changes are committed, then run `status` and `push` from the local machine.
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
git-ssh-sync status myproject
|
|
335
|
+
git-ssh-sync push myproject
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
Use `--dry-run` to inspect the planned operations and preflight checks before changing refs:
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
git-ssh-sync pull myproject --dry-run
|
|
342
|
+
git-ssh-sync push myproject --dry-run
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
## Workflow When Push Stops
|
|
346
|
+
|
|
347
|
+
`push` executes only when the branch on the origin side is an ancestor of the branch on the development environment side. It stops when origin has commits that have not been pulled yet, or when origin and the development environment have diverged.
|
|
348
|
+
|
|
349
|
+
In that case, run `pull` from the local machine to deliver origin changes to the development environment.
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
git-ssh-sync pull myproject
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
If `pull` cannot fast-forward, `git-ssh-sync` does not automatically merge or rebase. Resolve it with normal Git operations on the development environment, using either merge or rebase, then run `push` again from the local machine.
|
|
356
|
+
|
|
357
|
+
Example using merge:
|
|
358
|
+
|
|
359
|
+
```bash
|
|
360
|
+
cd ~/work/myproject
|
|
361
|
+
git fetch gitsync
|
|
362
|
+
git merge gitsync/main
|
|
363
|
+
# If there are conflicts, edit the files
|
|
364
|
+
git status
|
|
365
|
+
git add <resolved-files>
|
|
366
|
+
git commit
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
Example using rebase:
|
|
370
|
+
|
|
371
|
+
```bash
|
|
372
|
+
cd ~/work/myproject
|
|
373
|
+
git fetch gitsync
|
|
374
|
+
git rebase gitsync/main
|
|
375
|
+
# If there are conflicts, edit the files
|
|
376
|
+
git status
|
|
377
|
+
git add <resolved-files>
|
|
378
|
+
git rebase --continue
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
If the branch is not `main`, replace `gitsync/main` with the target branch. After merge or rebase completes, check status from the local machine and push.
|
|
382
|
+
|
|
383
|
+
```bash
|
|
384
|
+
git-ssh-sync status myproject
|
|
385
|
+
git-ssh-sync push myproject
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
After rebase, only rewrite commits that exist only on the development environment and have not been pushed to origin yet. If you want to avoid rewriting history on a shared branch, use merge.
|
|
389
|
+
|
|
191
390
|
## Branch Switching Workflow
|
|
192
391
|
|
|
193
392
|
To switch to an existing branch, execute `checkout` from the local machine.
|
|
@@ -204,6 +403,13 @@ To create a new branch, use `-b`. Use `--base` together to explicitly specify th
|
|
|
204
403
|
git-ssh-sync checkout myproject -b feature/foo --base develop
|
|
205
404
|
```
|
|
206
405
|
|
|
406
|
+
To preview a branch switch or branch creation without changing origin, cache, or work repo refs:
|
|
407
|
+
|
|
408
|
+
```bash
|
|
409
|
+
git-ssh-sync checkout myproject feature/foo --dry-run
|
|
410
|
+
git-ssh-sync checkout myproject -b feature/foo --base develop --dry-run
|
|
411
|
+
```
|
|
412
|
+
|
|
207
413
|
Development environment:
|
|
208
414
|
|
|
209
415
|
```bash
|
|
@@ -237,6 +443,20 @@ To list existence status and ahead/behind for each branch, use `branch`.
|
|
|
237
443
|
git-ssh-sync branch myproject
|
|
238
444
|
```
|
|
239
445
|
|
|
446
|
+
To inspect the development work repo directly from the local machine, use the
|
|
447
|
+
read-only `dev` commands.
|
|
448
|
+
|
|
449
|
+
```bash
|
|
450
|
+
git-ssh-sync dev status myproject
|
|
451
|
+
git-ssh-sync dev diff myproject
|
|
452
|
+
git-ssh-sync dev diff myproject --stat
|
|
453
|
+
git-ssh-sync dev log myproject --max-count 5
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
These commands run `git status`, `git diff`, or `git log` on the development
|
|
457
|
+
work repo over SSH. They do not update origin, the local gateway repo, the
|
|
458
|
+
development cache repo, or the development work repo refs.
|
|
459
|
+
|
|
240
460
|
## Operational Rules
|
|
241
461
|
|
|
242
462
|
When using `git-ssh-sync`, following these rules makes it easier to understand the state:
|
|
@@ -253,7 +473,7 @@ Uncommitted changes are not synchronized. If there are uncommitted changes in th
|
|
|
253
473
|
|
|
254
474
|
`push` executes only when the branch on the origin side is an ancestor of the branch on the development environment side. If there are unobtained commits on origin, it stops.
|
|
255
475
|
|
|
256
|
-
When diverged, automatic resolution is not performed.
|
|
476
|
+
When diverged, automatic resolution is not performed. Follow "Workflow When Push Stops", merge or rebase in the development environment, then `push` again.
|
|
257
477
|
|
|
258
478
|
## Common Commands
|
|
259
479
|
|
|
@@ -283,6 +503,12 @@ git-ssh-sync status myproject
|
|
|
283
503
|
# Check branch status
|
|
284
504
|
git-ssh-sync branch myproject
|
|
285
505
|
|
|
506
|
+
# Inspect development work repo status
|
|
507
|
+
git-ssh-sync dev status myproject
|
|
508
|
+
|
|
509
|
+
# Inspect development work repo diff
|
|
510
|
+
git-ssh-sync dev diff myproject --stat
|
|
511
|
+
|
|
286
512
|
# Reflect changes from origin to development environment
|
|
287
513
|
git-ssh-sync pull myproject
|
|
288
514
|
|
|
@@ -297,8 +523,61 @@ git-ssh-sync checkout myproject -b feature/foo --base develop
|
|
|
297
523
|
|
|
298
524
|
# Diagnostics
|
|
299
525
|
git-ssh-sync doctor myproject
|
|
526
|
+
|
|
527
|
+
# Diagnose and optionally repair after an interrupted sync
|
|
528
|
+
git-ssh-sync recover myproject
|
|
529
|
+
git-ssh-sync recover myproject --yes
|
|
300
530
|
```
|
|
301
531
|
|
|
532
|
+
## Logging
|
|
533
|
+
|
|
534
|
+
`git-ssh-sync` supports detailed logging for troubleshooting and monitoring synchronization operations.
|
|
535
|
+
|
|
536
|
+
### Log Levels
|
|
537
|
+
|
|
538
|
+
By default, only warnings and errors are displayed. You can increase verbosity using the following options:
|
|
539
|
+
|
|
540
|
+
- `--verbose`, `-v`: Enable INFO level logging (operation progress, Git/SSH commands)
|
|
541
|
+
- `--debug`, `-d`: Enable DEBUG level logging (all debug information, command output, stack traces)
|
|
542
|
+
|
|
543
|
+
### Log File Output
|
|
544
|
+
|
|
545
|
+
Logs are automatically saved to `~/.cache/git-ssh-sync/logs/git-ssh-sync.log`. The log file contains all log levels (DEBUG and above) regardless of console output settings.
|
|
546
|
+
|
|
547
|
+
You can specify a custom log file path using `--log-file`:
|
|
548
|
+
|
|
549
|
+
```bash
|
|
550
|
+
git-ssh-sync pull myproject --log-file /tmp/my-sync.log
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
### Usage Examples
|
|
554
|
+
|
|
555
|
+
```bash
|
|
556
|
+
# Default (warnings and errors only)
|
|
557
|
+
git-ssh-sync pull myproject
|
|
558
|
+
|
|
559
|
+
# Verbose output (operation progress)
|
|
560
|
+
git-ssh-sync pull myproject --verbose
|
|
561
|
+
|
|
562
|
+
# Debug output (all details including command execution)
|
|
563
|
+
git-ssh-sync pull myproject --debug
|
|
564
|
+
|
|
565
|
+
# Verbose with custom log file
|
|
566
|
+
git-ssh-sync push myproject --verbose --log-file /tmp/sync.log
|
|
567
|
+
|
|
568
|
+
# Debug output for diagnostics
|
|
569
|
+
git-ssh-sync doctor myproject --debug
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
### Log Content
|
|
573
|
+
|
|
574
|
+
- **INFO**: Operation progress (pull/push/checkout), success messages
|
|
575
|
+
- **DEBUG**: Git/SSH commands executed, return codes, stdout/stderr, working directories
|
|
576
|
+
- **WARNING**: Recoverable issues (LFS, submodules detected)
|
|
577
|
+
- **ERROR**: Failures, execution errors
|
|
578
|
+
|
|
579
|
+
Logs are particularly useful when troubleshooting SSH connection issues, Git command failures, or understanding the synchronization flow.
|
|
580
|
+
|
|
302
581
|
## For Developers
|
|
303
582
|
|
|
304
583
|
To develop this repository itself, install dependencies using `uv sync`.
|
|
@@ -79,8 +79,32 @@ Key parameters:
|
|
|
79
79
|
- `--origin`: Repository URL on the GitHub / GitLab side
|
|
80
80
|
- `--dev-host`: SSH host of the development environment
|
|
81
81
|
- `--dev-user`: SSH user of the development environment
|
|
82
|
+
- `--dev-os`: Development environment OS, either `posix` or `windows` (default: `posix`)
|
|
82
83
|
- `--dev-path`: Path to the work repository on the development environment
|
|
83
84
|
|
|
85
|
+
For a Windows development environment, specify `--dev-os windows` and use Windows
|
|
86
|
+
paths. Windows SSH commands are executed through PowerShell.
|
|
87
|
+
|
|
88
|
+
```powershell
|
|
89
|
+
git-ssh-sync init myproject `
|
|
90
|
+
--origin git@github.com:example/myproject.git `
|
|
91
|
+
--dev-host devserver `
|
|
92
|
+
--dev-user user `
|
|
93
|
+
--dev-os windows `
|
|
94
|
+
--dev-path 'C:\Users\user\work\myproject'
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
When running the command from macOS or Linux shells such as `zsh` or `bash`,
|
|
98
|
+
quote Windows paths that contain backslashes. Otherwise the shell can remove the
|
|
99
|
+
backslashes before `git-ssh-sync` receives the argument. You can also use forward
|
|
100
|
+
slashes, for example `C:/Users/user/work/myproject`.
|
|
101
|
+
|
|
102
|
+
When `--dev-os windows` is used, the default cache path is
|
|
103
|
+
`C:\Users\<dev-user>\.git-ssh-sync\cache\<project>.git`. `clone` stops if either
|
|
104
|
+
the configured work path or cache path already exists on the development
|
|
105
|
+
environment, so remove stale directories or use the attach/recover workflow for
|
|
106
|
+
existing repositories.
|
|
107
|
+
|
|
84
108
|
For `--origin`, specify a remote URL that can be used with `git clone` or `git fetch`. Main formats are:
|
|
85
109
|
|
|
86
110
|
```text
|
|
@@ -104,6 +128,59 @@ git-ssh-sync init myproject \
|
|
|
104
128
|
--force
|
|
105
129
|
```
|
|
106
130
|
|
|
131
|
+
### Configuration file
|
|
132
|
+
|
|
133
|
+
Project settings are saved as YAML. The default path depends on the local
|
|
134
|
+
machine where `git-ssh-sync` runs:
|
|
135
|
+
|
|
136
|
+
```text
|
|
137
|
+
macOS / Linux: ~/.config/git-ssh-sync/config.yaml
|
|
138
|
+
Windows: %APPDATA%\git-ssh-sync\config.yaml
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
A generated configuration looks like this:
|
|
142
|
+
|
|
143
|
+
```yaml
|
|
144
|
+
version: 1
|
|
145
|
+
|
|
146
|
+
projects:
|
|
147
|
+
myproject:
|
|
148
|
+
origin: git@github.com:example/myproject.git
|
|
149
|
+
|
|
150
|
+
local:
|
|
151
|
+
repo_path: ~/.git-ssh-sync/repos/myproject
|
|
152
|
+
|
|
153
|
+
dev:
|
|
154
|
+
host: devserver
|
|
155
|
+
user: user
|
|
156
|
+
os: posix
|
|
157
|
+
work_path: /home/user/work/myproject
|
|
158
|
+
cache_path: /home/user/.git-ssh-sync/cache/myproject.git
|
|
159
|
+
|
|
160
|
+
options:
|
|
161
|
+
sync_tags: true
|
|
162
|
+
lfs: false
|
|
163
|
+
submodules: false
|
|
164
|
+
ff_only: true
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Main fields:
|
|
168
|
+
|
|
169
|
+
- `origin`: GitHub / GitLab repository URL used by the local gateway repository
|
|
170
|
+
- `local.repo_path`: Local gateway repository path managed by `git-ssh-sync`
|
|
171
|
+
- `dev.host`, `dev.user`, `dev.os`: SSH connection target and remote OS
|
|
172
|
+
- `dev.work_path`: Work repository path on the development environment
|
|
173
|
+
- `dev.cache_path`: Bare cache repository path on the development environment
|
|
174
|
+
- `options.sync_tags`: Synchronize Git tags when pulling or pushing
|
|
175
|
+
- `options.lfs`: Reserved option for Git LFS support
|
|
176
|
+
- `options.submodules`: Reserved option for submodule support
|
|
177
|
+
- `options.ff_only`: Keep synchronization fast-forward only
|
|
178
|
+
|
|
179
|
+
In normal use, manage this file with `git-ssh-sync init` and
|
|
180
|
+
`git-ssh-sync config` commands. If you edit it manually, keep the YAML
|
|
181
|
+
structure unchanged and use paths that are valid on the machine or
|
|
182
|
+
development environment where each field is used.
|
|
183
|
+
|
|
107
184
|
You can inspect and maintain registered projects without opening the config file directly.
|
|
108
185
|
|
|
109
186
|
```bash
|
|
@@ -117,6 +194,7 @@ git-ssh-sync config show myproject
|
|
|
117
194
|
git-ssh-sync config set myproject \
|
|
118
195
|
--origin git@github.com:example/myproject.git \
|
|
119
196
|
--dev-host devserver \
|
|
197
|
+
--dev-os posix \
|
|
120
198
|
--dev-path /home/user/work/myproject
|
|
121
199
|
|
|
122
200
|
# Remove a project after confirmation
|
|
@@ -150,6 +228,54 @@ Afterward, the work repository on the development environment can be used as a n
|
|
|
150
228
|
|
|
151
229
|
`doctor` checks the local environment, SSH connection, fetch/push permissions to origin, and repository deployment on the development environment. Run this not only for the first time but also when synchronization is not working properly.
|
|
152
230
|
|
|
231
|
+
## Attaching Existing Repositories
|
|
232
|
+
|
|
233
|
+
If the gateway repository, development work repository, or cache repository already
|
|
234
|
+
exists, use `attach` instead of `clone`.
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
git-ssh-sync init myproject \
|
|
238
|
+
--origin git@github.com:example/myproject.git \
|
|
239
|
+
--dev-host devserver \
|
|
240
|
+
--dev-user user \
|
|
241
|
+
--dev-path /home/user/work/myproject
|
|
242
|
+
git-ssh-sync attach myproject --dry-run
|
|
243
|
+
git-ssh-sync attach myproject
|
|
244
|
+
git-ssh-sync doctor myproject
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
`attach` inspects the configured origin URL, current branch, development work
|
|
248
|
+
tree state, bare cache repository, and `gitsync` remote. Before changing
|
|
249
|
+
anything, it prints the operations it will apply. Use `--yes` for non-interactive
|
|
250
|
+
execution after reviewing the plan.
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
git-ssh-sync attach myproject --yes
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
If only the `gitsync` remote or cache wiring is missing or mismatched, run
|
|
257
|
+
`doctor --repair` to inspect and repair it through the same preflight checks.
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
git-ssh-sync doctor myproject --repair
|
|
261
|
+
git-ssh-sync doctor myproject --repair --yes
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
After an interrupted `pull` or `push`, use `recover` as the recovery-oriented
|
|
265
|
+
entry point. Without `--yes`, it diagnoses origin, gateway, cache, and work
|
|
266
|
+
repository state and prints concrete next actions. With `--yes`, it applies only
|
|
267
|
+
safe wiring repairs such as creating the cache repository, seeding the cache
|
|
268
|
+
branch, or fixing the `gitsync` remote.
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
git-ssh-sync recover myproject
|
|
272
|
+
git-ssh-sync recover myproject --yes
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
`attach` and `doctor --repair` do not commit, stash, merge, or rebase existing
|
|
276
|
+
work. If the development work tree is dirty, or if a path is not a compatible Git
|
|
277
|
+
repository, the command stops and prints the manual recovery action.
|
|
278
|
+
|
|
153
279
|
## Daily Development Workflow
|
|
154
280
|
|
|
155
281
|
For daily development, `pull` from the local machine before starting work, commit normally in the development environment, and finally `push` from the local machine.
|
|
@@ -177,6 +303,79 @@ git-ssh-sync push myproject
|
|
|
177
303
|
|
|
178
304
|
`pull` and `push` target the current branch of the work repository on the development environment. To synchronize a different branch, switch the work repository branch with `checkout` first.
|
|
179
305
|
|
|
306
|
+
If you are not sure about the current state at the beginning of work, first check synchronization status from the local machine and run `pull` when needed.
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
git-ssh-sync status myproject
|
|
310
|
+
git-ssh-sync pull myproject
|
|
311
|
+
git-ssh-sync dev status myproject
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
If `dev status` shows a dirty working tree on the development environment, uncommitted changes are not synchronized. Inspect the diff on the development environment and commit the changes you want to synchronize before `push`.
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
git-ssh-sync dev diff myproject --stat
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Before pushing, confirm that the development environment changes are committed, then run `status` and `push` from the local machine.
|
|
321
|
+
|
|
322
|
+
```bash
|
|
323
|
+
git-ssh-sync status myproject
|
|
324
|
+
git-ssh-sync push myproject
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
Use `--dry-run` to inspect the planned operations and preflight checks before changing refs:
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
git-ssh-sync pull myproject --dry-run
|
|
331
|
+
git-ssh-sync push myproject --dry-run
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
## Workflow When Push Stops
|
|
335
|
+
|
|
336
|
+
`push` executes only when the branch on the origin side is an ancestor of the branch on the development environment side. It stops when origin has commits that have not been pulled yet, or when origin and the development environment have diverged.
|
|
337
|
+
|
|
338
|
+
In that case, run `pull` from the local machine to deliver origin changes to the development environment.
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
git-ssh-sync pull myproject
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
If `pull` cannot fast-forward, `git-ssh-sync` does not automatically merge or rebase. Resolve it with normal Git operations on the development environment, using either merge or rebase, then run `push` again from the local machine.
|
|
345
|
+
|
|
346
|
+
Example using merge:
|
|
347
|
+
|
|
348
|
+
```bash
|
|
349
|
+
cd ~/work/myproject
|
|
350
|
+
git fetch gitsync
|
|
351
|
+
git merge gitsync/main
|
|
352
|
+
# If there are conflicts, edit the files
|
|
353
|
+
git status
|
|
354
|
+
git add <resolved-files>
|
|
355
|
+
git commit
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
Example using rebase:
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
cd ~/work/myproject
|
|
362
|
+
git fetch gitsync
|
|
363
|
+
git rebase gitsync/main
|
|
364
|
+
# If there are conflicts, edit the files
|
|
365
|
+
git status
|
|
366
|
+
git add <resolved-files>
|
|
367
|
+
git rebase --continue
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
If the branch is not `main`, replace `gitsync/main` with the target branch. After merge or rebase completes, check status from the local machine and push.
|
|
371
|
+
|
|
372
|
+
```bash
|
|
373
|
+
git-ssh-sync status myproject
|
|
374
|
+
git-ssh-sync push myproject
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
After rebase, only rewrite commits that exist only on the development environment and have not been pushed to origin yet. If you want to avoid rewriting history on a shared branch, use merge.
|
|
378
|
+
|
|
180
379
|
## Branch Switching Workflow
|
|
181
380
|
|
|
182
381
|
To switch to an existing branch, execute `checkout` from the local machine.
|
|
@@ -193,6 +392,13 @@ To create a new branch, use `-b`. Use `--base` together to explicitly specify th
|
|
|
193
392
|
git-ssh-sync checkout myproject -b feature/foo --base develop
|
|
194
393
|
```
|
|
195
394
|
|
|
395
|
+
To preview a branch switch or branch creation without changing origin, cache, or work repo refs:
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
git-ssh-sync checkout myproject feature/foo --dry-run
|
|
399
|
+
git-ssh-sync checkout myproject -b feature/foo --base develop --dry-run
|
|
400
|
+
```
|
|
401
|
+
|
|
196
402
|
Development environment:
|
|
197
403
|
|
|
198
404
|
```bash
|
|
@@ -226,6 +432,20 @@ To list existence status and ahead/behind for each branch, use `branch`.
|
|
|
226
432
|
git-ssh-sync branch myproject
|
|
227
433
|
```
|
|
228
434
|
|
|
435
|
+
To inspect the development work repo directly from the local machine, use the
|
|
436
|
+
read-only `dev` commands.
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
git-ssh-sync dev status myproject
|
|
440
|
+
git-ssh-sync dev diff myproject
|
|
441
|
+
git-ssh-sync dev diff myproject --stat
|
|
442
|
+
git-ssh-sync dev log myproject --max-count 5
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
These commands run `git status`, `git diff`, or `git log` on the development
|
|
446
|
+
work repo over SSH. They do not update origin, the local gateway repo, the
|
|
447
|
+
development cache repo, or the development work repo refs.
|
|
448
|
+
|
|
229
449
|
## Operational Rules
|
|
230
450
|
|
|
231
451
|
When using `git-ssh-sync`, following these rules makes it easier to understand the state:
|
|
@@ -242,7 +462,7 @@ Uncommitted changes are not synchronized. If there are uncommitted changes in th
|
|
|
242
462
|
|
|
243
463
|
`push` executes only when the branch on the origin side is an ancestor of the branch on the development environment side. If there are unobtained commits on origin, it stops.
|
|
244
464
|
|
|
245
|
-
When diverged, automatic resolution is not performed.
|
|
465
|
+
When diverged, automatic resolution is not performed. Follow "Workflow When Push Stops", merge or rebase in the development environment, then `push` again.
|
|
246
466
|
|
|
247
467
|
## Common Commands
|
|
248
468
|
|
|
@@ -272,6 +492,12 @@ git-ssh-sync status myproject
|
|
|
272
492
|
# Check branch status
|
|
273
493
|
git-ssh-sync branch myproject
|
|
274
494
|
|
|
495
|
+
# Inspect development work repo status
|
|
496
|
+
git-ssh-sync dev status myproject
|
|
497
|
+
|
|
498
|
+
# Inspect development work repo diff
|
|
499
|
+
git-ssh-sync dev diff myproject --stat
|
|
500
|
+
|
|
275
501
|
# Reflect changes from origin to development environment
|
|
276
502
|
git-ssh-sync pull myproject
|
|
277
503
|
|
|
@@ -286,8 +512,61 @@ git-ssh-sync checkout myproject -b feature/foo --base develop
|
|
|
286
512
|
|
|
287
513
|
# Diagnostics
|
|
288
514
|
git-ssh-sync doctor myproject
|
|
515
|
+
|
|
516
|
+
# Diagnose and optionally repair after an interrupted sync
|
|
517
|
+
git-ssh-sync recover myproject
|
|
518
|
+
git-ssh-sync recover myproject --yes
|
|
289
519
|
```
|
|
290
520
|
|
|
521
|
+
## Logging
|
|
522
|
+
|
|
523
|
+
`git-ssh-sync` supports detailed logging for troubleshooting and monitoring synchronization operations.
|
|
524
|
+
|
|
525
|
+
### Log Levels
|
|
526
|
+
|
|
527
|
+
By default, only warnings and errors are displayed. You can increase verbosity using the following options:
|
|
528
|
+
|
|
529
|
+
- `--verbose`, `-v`: Enable INFO level logging (operation progress, Git/SSH commands)
|
|
530
|
+
- `--debug`, `-d`: Enable DEBUG level logging (all debug information, command output, stack traces)
|
|
531
|
+
|
|
532
|
+
### Log File Output
|
|
533
|
+
|
|
534
|
+
Logs are automatically saved to `~/.cache/git-ssh-sync/logs/git-ssh-sync.log`. The log file contains all log levels (DEBUG and above) regardless of console output settings.
|
|
535
|
+
|
|
536
|
+
You can specify a custom log file path using `--log-file`:
|
|
537
|
+
|
|
538
|
+
```bash
|
|
539
|
+
git-ssh-sync pull myproject --log-file /tmp/my-sync.log
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
### Usage Examples
|
|
543
|
+
|
|
544
|
+
```bash
|
|
545
|
+
# Default (warnings and errors only)
|
|
546
|
+
git-ssh-sync pull myproject
|
|
547
|
+
|
|
548
|
+
# Verbose output (operation progress)
|
|
549
|
+
git-ssh-sync pull myproject --verbose
|
|
550
|
+
|
|
551
|
+
# Debug output (all details including command execution)
|
|
552
|
+
git-ssh-sync pull myproject --debug
|
|
553
|
+
|
|
554
|
+
# Verbose with custom log file
|
|
555
|
+
git-ssh-sync push myproject --verbose --log-file /tmp/sync.log
|
|
556
|
+
|
|
557
|
+
# Debug output for diagnostics
|
|
558
|
+
git-ssh-sync doctor myproject --debug
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
### Log Content
|
|
562
|
+
|
|
563
|
+
- **INFO**: Operation progress (pull/push/checkout), success messages
|
|
564
|
+
- **DEBUG**: Git/SSH commands executed, return codes, stdout/stderr, working directories
|
|
565
|
+
- **WARNING**: Recoverable issues (LFS, submodules detected)
|
|
566
|
+
- **ERROR**: Failures, execution errors
|
|
567
|
+
|
|
568
|
+
Logs are particularly useful when troubleshooting SSH connection issues, Git command failures, or understanding the synchronization flow.
|
|
569
|
+
|
|
291
570
|
## For Developers
|
|
292
571
|
|
|
293
572
|
To develop this repository itself, install dependencies using `uv sync`.
|