summaryrefslogtreecommitdiffstats
path: root/content/en/hardenedpass/using/sync/index.md
blob: d043cea92252cd95d859f817c479dbe32a5f187a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
+++
title = "Sync"
date = 2026-11-05T00:00:00Z
description = "How HardenedPass syncs your store with git: when changes are committed, how to pull and push, and how to recover from a conflict."
weight = 70
draft = false
+++

Every change you make in the app, such as a new entry, an edit or a delete, is
committed to git on the phone straight away. **Nothing is sent to the server until you
sync**, unless you turn on [Push after each change](#push-after-each-change). Until then,
the change exists only on this phone.

## Sync

Pull down on the list to synchronize. You can also use the three dots in the search
bar:

{{< image src="menu.png" alt="The list's menu with Synchronize repository, Pull from remote, Push to remote, Settings and About." class="max-w-sm mx-auto rounded-lg border border-border" />}}

- **Synchronize repository** fetches the server's changes and sends yours.
- **Pull from remote** only fetches.
- **Push to remote** only sends.

Synchronize is what you want almost every time. To turn the gesture off, use
**Disable pull to sync action** in
[Settings]({{< relref "/hardenedpass/reference/settings" >}}).

## Push after each change

Turn on **Push after each change** in **Settings**, then **Repository**, and every new
entry, edit, move, rename or delete made in the app is pushed right away. This keeps the
server up to date, so a change on a computer is less likely to collide with one waiting
on the phone. It is off by default.

Three things to know:

- Entries saved through autofill are not pushed. They stay on the phone until the next
  push or sync.
- It only sends. To get the server's changes you still need to sync.
- If your SSH key is protected by the screen lock, the app asks for it at every change.

If the push fails, for example with no network or when the server has newer changes, the
app shows `Saved on this device, but not pushed. Sync to try again`. Your change is safe
in a local commit: sync when you can.

## When two devices change the same thing

If you edit the same entry on the phone and on a computer before syncing, git cannot
pick a winner. The app uses a rebase by default (**Rebase on pull**), and the sync
stops with an error saying the pull failed and that you are in a detached head. Your
work is not lost.

Open **Settings**, then **Repository**, then **Local Git config & utilities**. You have two ways out:

### Keep your changes

**Abort rebase and push new branch** cancels the rebase and sends your local work to a
new branch on the server. The app tells you its name. Then, on a computer:

```bash
pass git fetch origin
pass git merge origin/BRANCH-NAME
```

Git stops on the entries that conflict. Encrypted files cannot be merged line by line,
so keep one version of each, finish the merge, and send it back with `pass git push`.
On the phone, finish with the hard reset below, so that the phone matches the server
again.

### Throw your changes away

**Hard reset to remote branch** asks for the branch name, then makes the phone an exact
copy of it.

{{< callout type="warning" >}}
A hard reset discards local commits and changes that are not on that remote branch. Use
it only when you are sure, or after saving your work with the option above.
{{< /callout >}}

## Other tools

The same screen sets the name and email used for commits, shows the commit log with
**Show commit log**, and offers **Run garbage collection job** to tidy up the local
repository.