git-ssh-sync 0.5.0__tar.gz → 0.6.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: git-ssh-sync
3
- Version: 0.5.0
3
+ Version: 0.6.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
@@ -23,8 +23,74 @@ Description-Content-Type: text/markdown
23
23
 
24
24
  This tool is designed for niche environments where outbound network access is restricted, such as high-security enterprises and projects that only allow limited inbound communication (e.g., SSH, RDP).
25
25
 
26
+ ## Start here
27
+
28
+ If you are new to `git-ssh-sync`, read these sections in order:
29
+
30
+ | Goal | Section |
31
+ |---|---|
32
+ | Check whether this tool fits your environment | [Who is this for?](#who-is-this-for) |
33
+ | Understand the repository layout | [Architecture](#architecture) |
34
+ | Install and run the shortest setup | [Quick start](#quick-start) |
35
+ | Register a real project | [Configuration](#configuration) |
36
+ | Work day to day | [Daily Development Workflow](#daily-development-workflow) |
37
+ | Recover from stopped synchronization | [Troubleshooting](#troubleshooting) |
38
+
39
+ The common path is:
40
+
41
+ 1. Install `git-ssh-sync` on the local machine.
42
+ 2. Register a project with `init`.
43
+ 3. Create or attach the development repositories with `clone` or `attach`.
44
+ 4. Run `pull` before editing and `push` after committing on the development environment.
45
+
46
+ ## Who is this for?
47
+
48
+ Use `git-ssh-sync` if:
49
+
50
+ - Your development environment cannot access GitHub / GitLab directly.
51
+ - Your local machine can access GitHub / GitLab.
52
+ - Your local machine can SSH into the development environment.
53
+ - You want to edit, build, test, and commit in the development environment.
54
+ - You want to synchronize by Git commits and branches instead of copying files manually.
55
+
56
+ If your development environment can already access GitHub / GitLab directly, you usually do not need this tool.
57
+
26
58
  This is not a file synchronization tool. It synchronizes Git objects and branches. Source editing, building, testing, and committing are performed in the development environment, while communication with GitHub/GitLab is handled by the local machine.
27
59
 
60
+ ## Architecture
61
+
62
+ `git-ssh-sync` keeps GitHub/GitLab access on the local machine and Git work on
63
+ the development environment.
64
+
65
+ ```text
66
+ origin: GitHub / GitLab
67
+ ↑↓
68
+ local gateway repo
69
+ ↑↓ git over SSH
70
+ dev bare cache repo
71
+ ↑↓
72
+ dev work repo
73
+ ```
74
+
75
+ Terms used throughout this document:
76
+
77
+ | Term | Meaning |
78
+ |---|---|
79
+ | `origin` | Original remote repository on GitHub / GitLab |
80
+ | `local gateway repo` | Relay repository on the local machine |
81
+ | `dev bare cache repo` | Bare repository on the development environment |
82
+ | `dev work repo` | Repository where you edit, build, test, and commit on the development environment |
83
+ | `gitsync remote` | Remote in the dev work repo that points to the dev bare cache repo |
84
+
85
+ ## Current limitations
86
+
87
+ The following features are not supported yet:
88
+
89
+ - Git LFS
90
+ - Git submodules
91
+ - automatic conflict resolution
92
+ - synchronizing uncommitted file changes
93
+
28
94
  ## Prerequisites
29
95
 
30
96
  `git-ssh-sync` assumes the following configuration:
@@ -37,20 +103,25 @@ Local machine
37
103
  Development environment
38
104
  ```
39
105
 
40
- Local machine:
106
+ | Place | Requirements |
107
+ |---|---|
108
+ | Local machine | Can access GitHub / GitLab, can SSH to the development environment, and has `git` and `uv` available |
109
+ | Development environment | Can be accessed via SSH from the local machine, has `git` available, and does not need direct GitHub / GitLab access |
41
110
 
42
- - Can access GitHub / GitLab
43
- - Can SSH to the development environment
44
- - Has `git` and `uv` available
45
- - Uses `git-ssh-sync` for commit synchronization, status checks, and diagnostics between GitHub/GitLab and the development environment
111
+ Run `git-ssh-sync` on the local machine. Edit, build, test, and commit on the
112
+ development environment. Synchronization between the two sides happens through
113
+ Git commits and branches.
46
114
 
47
- Development environment:
115
+ ## Safety model
116
+
117
+ `git-ssh-sync` does not:
48
118
 
49
- - Can be accessed via SSH from the local machine
50
- - Cannot directly access GitHub / GitLab from the development environment
51
- - Has `git` available
52
- - Performs source editing, building, testing, and committing
53
- - Synchronizes with GitHub/GitLab via the local machine
119
+ - Synchronize uncommitted files
120
+ - Automatically merge or rebase branches
121
+ - Force-push to origin
122
+ - Modify a dirty development work tree
123
+ - Require GitHub/GitLab credentials on the development environment
124
+ - Require direct outbound access from the development environment to GitHub/GitLab
54
125
 
55
126
  ## Installation
56
127
 
@@ -72,6 +143,37 @@ After installation, verify that the command can be executed.
72
143
  git-ssh-sync --help
73
144
  ```
74
145
 
146
+ ## Quick start
147
+
148
+ After installing `git-ssh-sync`, the shortest path from setup to daily sync is:
149
+
150
+ ```bash
151
+ uv tool install git-ssh-sync
152
+
153
+ git-ssh-sync init myproject \
154
+ --origin git@github.com:example/myproject.git \
155
+ --dev-host devserver \
156
+ --dev-user user \
157
+ --dev-path /home/user/work/myproject
158
+
159
+ git-ssh-sync clone myproject
160
+ git-ssh-sync doctor myproject
161
+
162
+ git-ssh-sync pull myproject
163
+
164
+ # On the development environment:
165
+ # cd ~/work/myproject
166
+ # git add .
167
+ # git commit -m "Add feature"
168
+
169
+ git-ssh-sync status myproject
170
+ git-ssh-sync push myproject
171
+ ```
172
+
173
+ Run `clone` and `doctor` for the first setup. For regular work, run `pull`
174
+ before editing, commit on the development environment, then check `status` and
175
+ run `push` from the local machine.
176
+
75
177
  ## Configuration
76
178
 
77
179
  First, register the project you want to synchronize.
@@ -182,7 +284,7 @@ Main fields:
182
284
  - `dev.host`, `dev.user`, `dev.os`: SSH connection target and remote OS
183
285
  - `dev.work_path`: Work repository path on the development environment
184
286
  - `dev.cache_path`: Bare cache repository path on the development environment
185
- - `options.sync_tags`: Synchronize Git tags when pulling or pushing
287
+ - `options.sync_tags`: Enable explicit Git tag synchronization
186
288
  - `options.lfs`: Reserved option for Git LFS support
187
289
  - `options.submodules`: Reserved option for submodule support
188
290
  - `options.ff_only`: Keep synchronization fast-forward only
@@ -229,11 +331,8 @@ git-ssh-sync clone myproject
229
331
  git-ssh-sync doctor myproject
230
332
  ```
231
333
 
232
- `clone` creates a gateway repository on your local machine and deploys cache and work repositories on the development environment.
233
-
234
- - Gateway repository: Relay repository on the local machine
235
- - Cache repository: Bare repository on the development environment
236
- - Work repository: Repository where actual editing, building, testing, and committing are performed on the development environment
334
+ `clone` creates the local gateway repo and deploys the dev bare cache repo and
335
+ dev work repo described above.
237
336
 
238
337
  Afterward, the work repository on the development environment can be used as a normal Git repository.
239
338
 
@@ -264,6 +363,16 @@ execution after reviewing the plan.
264
363
  git-ssh-sync attach myproject --yes
265
364
  ```
266
365
 
366
+ Use this table to choose between setup diagnostics, wiring repair, and recovery
367
+ after an interrupted sync.
368
+
369
+ | Situation | Command |
370
+ |---|---|
371
+ | Check initial setup or connectivity | `git-ssh-sync doctor myproject` |
372
+ | Repair missing or mismatched `gitsync` remote/cache wiring | `git-ssh-sync doctor myproject --repair` |
373
+ | Diagnose after interrupted `pull` / `push` | `git-ssh-sync recover myproject` |
374
+ | Apply only safe wiring repairs after interruption | `git-ssh-sync recover myproject --yes` |
375
+
267
376
  If only the `gitsync` remote or cache wiring is missing or mismatched, run
268
377
  `doctor --repair` to inspect and repair it through the same preflight checks.
269
378
 
@@ -342,6 +451,35 @@ git-ssh-sync pull myproject --dry-run
342
451
  git-ssh-sync push myproject --dry-run
343
452
  ```
344
453
 
454
+ ## Tag Synchronization Workflow
455
+
456
+ Tags are synchronized explicitly so release refs are not changed during normal
457
+ branch `pull` / `push` operations. `sync-tags` only creates missing tags. It
458
+ stops when an existing tag name points to a different object, and it does not
459
+ delete, overwrite, or force-update tags.
460
+
461
+ To bring release tags from origin into the development environment:
462
+
463
+ ```bash
464
+ git-ssh-sync sync-tags myproject --dry-run
465
+ git-ssh-sync sync-tags myproject
466
+ ```
467
+
468
+ To publish tags created in the development work repository back to origin:
469
+
470
+ ```bash
471
+ git-ssh-sync sync-tags myproject --direction dev-to-origin --dry-run
472
+ git-ssh-sync sync-tags myproject --direction dev-to-origin
473
+ ```
474
+
475
+ Recommended release flow:
476
+
477
+ 1. Run `git-ssh-sync pull myproject` before release work.
478
+ 2. Create the release tag in the development work repository.
479
+ 3. Run `git-ssh-sync sync-tags myproject --direction dev-to-origin --dry-run`.
480
+ 4. If the dry-run reports only the intended new tag, run the command without
481
+ `--dry-run`.
482
+
345
483
  ## Workflow When Push Stops
346
484
 
347
485
  `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.
@@ -443,6 +581,27 @@ To list existence status and ahead/behind for each branch, use `branch`.
443
581
  git-ssh-sync branch myproject
444
582
  ```
445
583
 
584
+ To remove a branch after checking the affected refs, use `branch delete`.
585
+ The command stops if the development work repo is currently on that branch.
586
+
587
+ ```bash
588
+ git-ssh-sync branch delete myproject feature/foo --dry-run
589
+ git-ssh-sync branch delete myproject feature/foo
590
+ git-ssh-sync branch delete myproject feature/foo --yes
591
+ ```
592
+
593
+ To remove cache, work repo, and gateway tracking refs for branches that no longer
594
+ exist on origin, use `branch prune`.
595
+
596
+ ```bash
597
+ git-ssh-sync branch prune myproject --dry-run
598
+ git-ssh-sync branch prune myproject
599
+ ```
600
+
601
+ Branch rename is intentionally not automated yet. Rename a branch with normal Git
602
+ operations, then use `checkout`, `push`, `branch delete`, or `branch prune` to
603
+ bring each repository back into the intended state.
604
+
446
605
  To inspect the development work repo directly from the local machine, use the
447
606
  read-only `dev` commands.
448
607
 
@@ -477,58 +636,208 @@ When diverged, automatic resolution is not performed. Follow "Workflow When Push
477
636
 
478
637
  ## Common Commands
479
638
 
639
+ | Goal | Command |
640
+ |---|---|
641
+ | Display help | `git-ssh-sync --help` |
642
+ | Register a project | `git-ssh-sync init myproject --origin git@github.com:example/myproject.git --dev-host devserver --dev-user user --dev-path /home/user/work/myproject` |
643
+ | List registered project settings | `git-ssh-sync config list` |
644
+ | Show registered project settings | `git-ssh-sync config show myproject` |
645
+ | Initial clone | `git-ssh-sync clone myproject` |
646
+ | Check synchronization status | `git-ssh-sync status myproject` |
647
+ | Check branch status | `git-ssh-sync branch myproject` |
648
+ | Delete a branch after reviewing affected refs | `git-ssh-sync branch delete myproject feature/foo` |
649
+ | Prune refs for branches missing on origin | `git-ssh-sync branch prune myproject` |
650
+ | Inspect development work repo status | `git-ssh-sync dev status myproject` |
651
+ | Inspect development work repo diff | `git-ssh-sync dev diff myproject --stat` |
652
+ | Reflect changes from origin to development environment | `git-ssh-sync pull myproject` |
653
+ | Reflect commits from development environment to origin | `git-ssh-sync push myproject` |
654
+ | Switch development environment branch | `git-ssh-sync checkout myproject feature/foo` |
655
+ | Create and switch to a new branch from a base branch | `git-ssh-sync checkout myproject -b feature/foo --base develop` |
656
+ | Diagnostics | `git-ssh-sync doctor myproject` |
657
+ | Diagnose after an interrupted sync | `git-ssh-sync recover myproject` |
658
+ | Apply safe recovery repairs | `git-ssh-sync recover myproject --yes` |
659
+
660
+ For commands with many options, prefer the full examples in the workflow
661
+ sections above. They are easier to copy safely because each option is shown on
662
+ its own line.
663
+
664
+ ## Troubleshooting
665
+
666
+ Use `status` first when synchronization stops or the current state is unclear.
667
+ Use `doctor` for setup, connectivity, and repository wiring problems. Use
668
+ `recover` after an interrupted `pull` or `push`.
669
+ For a fuller operational guide, see [Troubleshooting](docs/troubleshooting.md).
670
+
671
+ ### push stops because origin has new commits
672
+
673
+ Cause:
674
+ origin has commits that are not included in the development environment branch,
675
+ or origin and the development environment branch have diverged.
676
+
677
+ Check:
678
+
480
679
  ```bash
481
- # Display help
482
- git-ssh-sync --help
680
+ git-ssh-sync status myproject
681
+ ```
483
682
 
484
- # Register a project
485
- git-ssh-sync init myproject \
486
- --origin git@github.com:example/myproject.git \
487
- --dev-host devserver \
488
- --dev-user user \
489
- --dev-path /home/user/work/myproject
683
+ Fix:
490
684
 
491
- # List registered project settings
492
- git-ssh-sync config list
685
+ ```bash
686
+ git-ssh-sync pull myproject
687
+ # If pull cannot fast-forward, merge or rebase in the development environment.
688
+ # See "Workflow When Push Stops" for the detailed recovery flow.
689
+ ```
493
690
 
494
- # Show registered project settings
495
- git-ssh-sync config show myproject
691
+ ### pull cannot fast-forward
496
692
 
497
- # Initial clone
498
- git-ssh-sync clone myproject
693
+ Cause:
694
+ origin and the development environment branch have diverged. `git-ssh-sync`
695
+ does not perform automatic merge or automatic rebase.
696
+
697
+ Check:
499
698
 
500
- # Check synchronization status
699
+ ```bash
501
700
  git-ssh-sync status myproject
701
+ git-ssh-sync dev status myproject
702
+ ```
502
703
 
503
- # Check branch status
504
- git-ssh-sync branch myproject
704
+ Fix:
505
705
 
506
- # Inspect development work repo status
507
- git-ssh-sync dev status myproject
706
+ ```bash
707
+ # On the development environment
708
+ cd ~/work/myproject
709
+ git fetch gitsync
710
+ git merge gitsync/main
711
+ # or: git rebase gitsync/main
712
+ ```
713
+
714
+ After resolving conflicts and committing or continuing the rebase, run:
508
715
 
509
- # Inspect development work repo diff
716
+ ```bash
717
+ git-ssh-sync status myproject
718
+ git-ssh-sync push myproject
719
+ ```
720
+
721
+ ### Development work repo is dirty
722
+
723
+ Cause:
724
+ the development environment work repo has uncommitted changes. Uncommitted
725
+ changes are not synchronized, and repair commands do not commit, stash, merge,
726
+ or rebase them automatically.
727
+
728
+ Check:
729
+
730
+ ```bash
731
+ git-ssh-sync dev status myproject
510
732
  git-ssh-sync dev diff myproject --stat
733
+ ```
511
734
 
512
- # Reflect changes from origin to development environment
513
- git-ssh-sync pull myproject
735
+ Fix:
514
736
 
515
- # Reflect commits from development environment to origin
516
- git-ssh-sync push myproject
737
+ ```bash
738
+ # On the development environment
739
+ cd ~/work/myproject
740
+ git status
741
+ git add <files-to-sync>
742
+ git commit
743
+ ```
517
744
 
518
- # Switch development environment branch
519
- git-ssh-sync checkout myproject feature/foo
745
+ Commit changes that should be synchronized, or stash/remove local-only changes
746
+ before running `pull`, `push`, `attach`, or `doctor --repair` again.
520
747
 
521
- # Create and switch to new branch from base branch
522
- git-ssh-sync checkout myproject -b feature/foo --base develop
748
+ ### gitsync remote is missing or mismatched
749
+
750
+ Cause:
751
+ the `gitsync` remote in the development work repo does not point to the expected
752
+ bare cache repo, or the wiring is missing.
753
+
754
+ Check:
523
755
 
524
- # Diagnostics
756
+ ```bash
525
757
  git-ssh-sync doctor myproject
758
+ ```
526
759
 
527
- # Diagnose and optionally repair after an interrupted sync
528
- git-ssh-sync recover myproject
529
- git-ssh-sync recover myproject --yes
760
+ Fix:
761
+
762
+ ```bash
763
+ git-ssh-sync doctor myproject --repair
764
+ git-ssh-sync doctor myproject --repair --yes
530
765
  ```
531
766
 
767
+ ### Cache repo or work repo already exists
768
+
769
+ Cause:
770
+ `clone` was asked to create a development work repo or bare cache repo at a path
771
+ that already exists.
772
+
773
+ Check:
774
+
775
+ ```bash
776
+ git-ssh-sync doctor myproject
777
+ ```
778
+
779
+ Fix:
780
+
781
+ ```bash
782
+ git-ssh-sync attach myproject --dev-path /home/user/work/myproject
783
+ git-ssh-sync doctor myproject --repair
784
+ ```
785
+
786
+ Use `attach` when the existing repositories are intentional. Otherwise choose an
787
+ empty path or move the existing directory before running `clone` again.
788
+
789
+ ### Windows path is broken
790
+
791
+ Cause:
792
+ the local shell may consume backslashes in Windows paths before
793
+ `git-ssh-sync` receives them, or the project may be configured with the wrong
794
+ development OS.
795
+
796
+ Check:
797
+
798
+ ```bash
799
+ git-ssh-sync config show myproject
800
+ git-ssh-sync doctor myproject
801
+ ```
802
+
803
+ Fix:
804
+
805
+ ```bash
806
+ git-ssh-sync init myproject \
807
+ --origin git@github.com:example/myproject.git \
808
+ --dev-host devserver \
809
+ --dev-user user \
810
+ --dev-os windows \
811
+ --dev-path 'C:\Users\user\work\myproject'
812
+ ```
813
+
814
+ Quote Windows paths that contain backslashes when running commands from macOS or
815
+ Linux shells.
816
+
817
+ ### SSH connection fails
818
+
819
+ Cause:
820
+ the local machine cannot connect to the development environment over SSH, or the
821
+ configured host, user, port, or authentication settings are incorrect.
822
+
823
+ Check:
824
+
825
+ ```bash
826
+ git-ssh-sync doctor myproject
827
+ ssh user@devserver
828
+ ```
829
+
830
+ Fix:
831
+
832
+ ```bash
833
+ git-ssh-sync config show myproject
834
+ # Update the project config or recreate it with the correct --dev-host,
835
+ # --dev-user, --dev-port, and SSH authentication settings.
836
+ ```
837
+
838
+ Run `doctor --debug` or use `--log-file` when you need the exact SSH and Git
839
+ commands used during diagnosis.
840
+
532
841
  ## Logging
533
842
 
534
843
  `git-ssh-sync` supports detailed logging for troubleshooting and monitoring synchronization operations.
@@ -610,4 +919,5 @@ uv run pytest
610
919
 
611
920
  ## Related Documentation
612
921
 
922
+ - [Troubleshooting](docs/troubleshooting.md)
613
923
  - [Specification](docs/spec.md)