@ariian/syncback
v1.1.1
Published
Automatically merge your branch into a target, push, and switch back
Maintainers
Readme
↺ syncback
Automatically merge your branch into a target, push, and switch back — all in one command.
The problem
Every time you need to push your work to main, production, or release you do this manually:
git checkout main
git pull origin main
git merge feature/my-branch
git push origin main
git checkout feature/my-branch # easy to forget!One slip — forgetting to switch back, or leaving a dirty state after a conflict — and you're in trouble.
The solution
syncback --into mainsyncback handles the full round trip: switch → pull → merge → push → switch back. If anything goes wrong it aborts cleanly and returns you to your original branch automatically.
Install
npm install -g @ariian/syncbackUsage
# merge current branch into main
syncback --into main
# merge a specific branch into release
syncback --from feature/payments --into release
# merge into multiple targets at once
syncback --into main --into staging
# merge but don't push
syncback --into main --no-push
# preview what it will do without executing
syncback --into main --dry-run
# use a different remote
syncback --into main --remote upstreamOptions
| Option | Description | Default |
|--------------------------|------------------------------------------|------------------|
| -f, --from <branch> | Source branch to merge from | current branch |
| -i, --into <branches...> | Target branch(es) to merge into | required |
| -r, --remote <remote> | Git remote to push to | origin |
| -n, --no-push | Merge locally, don't push | false |
| -d, --dry-run | Preview commands without executing | false |
| --no-stash | Don't auto-stash uncommitted changes | false |
How it works
Given you're on feature/my-branch and run syncback --into main:
1. detect current branch → feature/my-branch
2. git checkout main
3. git pull origin main → get latest
4. git merge feature/my-branch
5. git push origin main
6. git checkout feature/my-branch ← back homeIf you pass multiple targets with --into main --into staging, it repeats the round trip for each one, showing a [1/2] / [2/2] counter, and always returns you home at the end.
Each git operation shows a live spinner so you can see exactly what's running and whether it succeeded or failed.
Conflict safety
If a merge conflict is detected, syncback will:
- Abort the merge immediately
- Return you to your original branch
- Leave your working tree clean
- Report exactly which target failed in the summary
You'll never be left stranded on the wrong branch. When syncing multiple targets, a failure on one target does not stop the rest — syncback continues and reports all results at the end.
Auto stash
If you have uncommitted changes, syncback automatically stashes them before switching branches and restores them when it's done. Use --no-stash to disable this.
Dry run
Not sure what syncback will do? Run with --dry-run to preview every git command without executing any of them:
syncback --into main --into staging --dry-runOutput:
DRY RUN — no changes will be made
$ git checkout main
$ git pull origin main
$ git merge feature/my-branch
$ git push origin main
$ git checkout feature/my-branch
$ git checkout staging
$ git pull origin staging
$ git merge feature/my-branch
$ git push origin staging
$ git checkout feature/my-branchLicense
MIT © Arian Najafi Yamchelo — arii.dev
