/ radicle-cli / examples / git / git-push.md
git-push.md
 1  ```
 2  $ git checkout -b alice/1
 3  $ git commit -m "Alice's commit" --allow-empty -s
 4  [alice/1 87fa120] Alice's commit
 5  ```
 6  
 7  ``` (stderr) RAD_SOCKET=/dev/null
 8  $ git push rad HEAD:alice/1
 9  To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
10   * [new branch]      HEAD -> alice/1
11  ```
12  
13  Make sure we can't force-push without `+`:
14  
15  ``` (stderr)
16  $ git commit --amend -m "Alice's amended commit" --allow-empty -s
17  ```
18  ``` (stderr) (fail)
19  $ git push rad HEAD:alice/1
20  To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
21   ! [rejected]        HEAD -> alice/1 (non-fast-forward)
22  error: failed to push some refs to 'rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi'
23  hint: [..]
24  hint: [..]
25  hint: [..]
26  hint: See the 'Note about fast-forwards' in 'git push --help' for details.
27  ```
28  
29  And that we can with `+`:
30  
31  ``` (stderr)
32  $ git push -o no-sync rad +HEAD:alice/1
33  To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
34   + 87fa120...145e1e6 HEAD -> alice/1 (forced update)
35  ```
36  
37  Notice that we used the `-o no-sync` push option to disable syncing after the push.
38  
39  ```
40  $ git branch -r -vv
41    rad/alice/1 145e1e6 Alice's amended commit
42    rad/master  f2de534 Second commit
43  ```
44  
45  List our namespaced refs:
46  
47  ```
48  $ git ls-remote rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi 'refs/heads/*'
49  145e1e69bef3ad93d14946ea212249c2fa9b9828	refs/heads/alice/1
50  f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354	refs/heads/master
51  ```
52  
53  List the canonical refs:
54  
55  ```
56  $ git ls-remote rad
57  f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354	refs/heads/master
58  ```
59  
60  ```
61  $ rad sync --announce
62  ✓ Synced with 1 node(s)
63  ```
64  
65  Note that it is forbidden to delete the default/canonical branch:
66  
67  ``` (fail) (stderr)
68  $ git push rad :master
69  error: refusing to delete default branch ref 'refs/heads/master'
70  error: failed to push some refs to 'rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi'
71  ```