Skip to content

Commit 322768e

Browse files
committed
Remotes: repository from scratch
1 parent 1be1854 commit 322768e

File tree

1 file changed

+52
-43
lines changed

1 file changed

+52
-43
lines changed

docs/remotes.md

Lines changed: 52 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,21 @@ $ git graph
6363

6464
A remote repository can be added manually with the command
6565

66-
```java
66+
```bash
6767
$ git remote add remote_name location
6868

69-
$ git remote add remote_name git@github.com:aliceuser2020/my-first-project.git
69+
# Example
70+
mkdyr my-repo && cd my-repo
71+
git init
72+
$ git remote add origin git@github.com:pojeda/my-first-project.git
7073

7174
$ git remote -v
72-
remote_name git@github.com:aliceuser2020/my-first-project.git (fetch)
73-
remote_name git@github.com:aliceuser2020/my-first-project.git (push)
75+
origin git@github.com:pojeda/my-first-project.git (fetch)
76+
origin git@github.com:pojeda/my-first-project.git (push)
7477
```
7578

7679
where the location of the remote can be an URL or the path if that is in your local machine.
7780

78-
7981
---
8082

8183
Protocols:
@@ -88,44 +90,7 @@ Protocols:
8890

8991
---
9092

91-
Do we need more than one remote?
92-
93-
94-
```mermaid
95-
graph TD
96-
97-
bob{"Bob repo"}
98-
origin["origin"]
99-
style origin fill:#ffffff,stroke:#ffffff,color:#ff0000
100-
upstream["upstream"]
101-
style upstream fill:#ffffff,stroke:#ffffff,color:#ff0000
102-
upstream -.-> bob
103-
origin -.-> alicef
104-
105-
alicef(["Alice fork"])
106-
alicel(["Alice local"])
107-
108-
bob --> alicef
109-
110-
alicef --> alicel
111-
alicel -.-> bob
112-
```
113-
114-
---
115-
116-
117-
```java
118-
$ git remote add upstream git@github.com:bob/my-first-project.git
119-
120-
$ git remote -v
121-
origin git@github.com:aliceuser2020/my-first-project.git (fetch)
122-
origin git@github.com:aliceuser2020/my-first-project.git (push)
123-
upstream git@github.com:bobuser2020/my-first-project.git (fetch)
124-
upstream git@github.com:bobuser2020/my-first-project.git (push)
125-
```
126-
12793

128-
---
12994

13095
```java
13196
$git graph
@@ -197,7 +162,6 @@ $ git merge
197162

198163
---
199164

200-
## Advanced
201165
The command
202166
```shell
203167
$ git push
@@ -206,6 +170,7 @@ will send the changes in the current branch to the remote by default.
206170

207171
---
208172

173+
## Advanced
209174

210175
The default behavior can be seen with:
211176
```shell
@@ -429,10 +394,54 @@ Then, Alice will see the forked repository on her user space:
429394

430395
---
431396

397+
How do we add the upstream remote?
398+
399+
```mermaid
400+
graph TD
401+
402+
bob{"Bob repo"}
403+
origin["origin"]
404+
style origin fill:#ffffff,stroke:#ffffff,color:#ff0000
405+
upstream["upstream"]
406+
style upstream fill:#ffffff,stroke:#ffffff,color:#ff0000
407+
upstream -.-> bob
408+
origin -.-> alicef
409+
410+
alicef(["Alice fork"])
411+
alicel(["Alice local"])
412+
413+
bob --> alicef
414+
415+
alicef --> alicel
416+
alicel -.-> bob
417+
```
418+
419+
---
420+
421+
422+
```java
423+
$ git remote add upstream git@github.com:bob/my-first-project.git
424+
425+
$ git remote -v
426+
origin git@github.com:aliceuser2020/my-first-project.git (fetch)
427+
origin git@github.com:aliceuser2020/my-first-project.git (push)
428+
upstream git@github.com:bobuser2020/my-first-project.git (fetch)
429+
upstream git@github.com:bobuser2020/my-first-project.git (push)
430+
```
431+
432+
Alice can used the forked repository as the *origin* where she can put her changes. The *upstream* remote
433+
will help her to be updated with the latest changes from Bob (Github will show messages) but she won't be
434+
able to commit changes to Bob's repo (without permissions).
435+
436+
---
437+
438+
## Synchronizing remotes
439+
432440
After doing some changes, Alice push them to her forked repository but she wants Bob become aware of them (1 commit in this case, click on this commit)
433441

434442
![push repo](../images/alice-commit.png)
435443

444+
436445
---
437446

438447
## Pull request

0 commit comments

Comments
 (0)