Skip to content

Commit 2f1a874

Browse files
authored
Merge pull request #256 from carpentries-incubator/issues-173
Expanded diagram to include git pull using Mermaid JS tool.
2 parents ed19501 + de1c5d5 commit 2f1a874

3 files changed

Lines changed: 625 additions & 15 deletions

File tree

_episodes/14-collaboration-using-git.md

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ Git has several important characteristics:
5757
so even if you make a mistake you can revert to a point before it.
5858

5959
The diagram below shows a typical software development lifecycle with Git
60-
and the commonly used commands to interact
61-
with different parts of Git infrastructure,
60+
(starting from making changes locally) and the commonly used commands to interact
61+
with different parts of the Git infrastructure,
6262
such as:
6363
- **working directory** -
64-
a directory (including any subdirectories) where your project files live
64+
a local directory (including any subdirectories) where your project files live
6565
and where you are currently working.
6666
It is also known as the “untracked” area of Git.
6767
Any changes to files will be marked by Git in the working directory.
@@ -72,32 +72,50 @@ such as:
7272
- **staging area (index)** -
7373
once you tell Git to start tracking changes to files
7474
(with `git add filename` command),
75-
Git saves those changes in the staging area.
75+
Git saves those changes in the staging area on your local machine.
7676
Each subsequent change to the same file needs to be followed by another `git add filename` command
7777
to tell Git to update it in the staging area.
7878
To see what is in your working directory and staging area at any moment
7979
(i.e. what changes is Git tracking),
8080
run the command `git status`.
8181
- **local repository** -
82-
stored within the `.git` directory of your project,
82+
stored within the `.git` directory of your project locally,
8383
this is where Git wraps together all your changes from the staging area
8484
and puts them using the `git commit` command.
8585
Each commit is a new, permanent snapshot (checkpoint, record) of your project in time,
86-
which you can share or revert back to.
86+
which you can share or revert to.
8787
- **remote repository** -
8888
this is a version of your project that is hosted somewhere on the Internet
89-
(e.g. on GitHub, GitLab or somewhere else).
89+
(e.g., on GitHub, GitLab or somewhere else).
9090
While your project is nicely version-controlled in your local repository,
9191
and you have snapshots of its versions from the past,
92-
if your machine crashes - you still may lose all your work.
93-
Working with a remote repository involves pushing your changes
94-
and pulling other people's changes to keep your local repository in sync
95-
in order to collaborate with others and to backup your work on a different machine.
96-
97-
![Development lifecycle with Git](../fig/git-lifecycle.png){: .image-with-shadow width="600px"}
92+
if your machine crashes - you still may lose all your work. Furthermore, you cannot
93+
share or collaborate on this local work with others easily.
94+
Working with a remote repository involves pushing your local changes remotely
95+
(using `git push`) and pulling other people's changes from a remote repository to
96+
your local copy (using `git fetch` or `git pull`) to keep the two in sync
97+
in order to collaborate (with a bonus that your work also gets backed up to another machine).
98+
Note that a common best practice when collaborating with others on a shared repository
99+
is to always do a `git pull` before a `git push`, to ensure you have any latest changes before you push your own.
100+
101+
<!--
102+
Created with https://mermaid.live/edit#pako:eNqVUj1PwzAQ_SvWTSCK2D1UQuoISzuwZDnsi2PVzgXnLBRV_e_YiSoKUZHwdL57T-_dxwkMWwINI31k6g3tPLqEselVeW-cjr53aucTGeE0PW63DwdBV5PPiVAr50WhtQv-ulShL2wwqD0NPPpKX-CGY_SyMH4jKmtPkYVWtCGP3UJaAW5rtSSmuy31o5fZW0fmyFn-QYmUHP1hbDXESzshqLux4yQmF6Ocvg2XXwj8SVa9T-ra1tMsdg8bKEFEb8vmTlW7AekoUgO6hJZazEEaaPpzgWIWPky9AS0p0wbyYFEuiwbdYhhLlmx1_Lpcw3wU5y-9M7w9
103+
sequenceDiagram
104+
Working Directory->>+Staging Area: git add
105+
Staging Area->>+Local Repository: git commit
106+
Local Repository->>+Remote Repository: git push
107+
Remote Repository->>+Local Repository: git fetch
108+
Local Repository->>+Staging Area:git checkout
109+
Local Repository->>+Staging Area:git merge
110+
Remote Repository->>+Working Directory: git pull (shortcut for git fetch followed by git checkout/merge)
111+
-->
112+
<!--
113+
SVG of the diagram can be downloaded from:
114+
[![](https://mermaid.ink/img/pako:eNqVUj1PwzAQ_SvWTSCK2D1UQuoISzuwZDnsi2PVzgXnLBRV_e_YiSoKUZHwdL57T-_dxwkMWwINI31k6g3tPLqEselVeW-cjr53aucTGeE0PW63DwdBV5PPiVAr50WhtQv-ulShL2wwqD0NPPpKX-CGY_SyMH4jKmtPkYVWtCGP3UJaAW5rtSSmuy31o5fZW0fmyFn-QYmUHP1hbDXESzshqLux4yQmF6Ocvg2XXwj8SVa9T-ra1tMsdg8bKEFEb8vmTlW7AekoUgO6hJZazEEaaPpzgWIWPky9AS0p0wbyYFEuiwbdYhhLlmx1_Lpcw3wU5y-9M7w9?type=png)](https://mermaid.live/edit#pako:eNqVUj1PwzAQ_SvWTSCK2D1UQuoISzuwZDnsi2PVzgXnLBRV_e_YiSoKUZHwdL57T-_dxwkMWwINI31k6g3tPLqEselVeW-cjr53aucTGeE0PW63DwdBV5PPiVAr50WhtQv-ulShL2wwqD0NPPpKX-CGY_SyMH4jKmtPkYVWtCGP3UJaAW5rtSSmuy31o5fZW0fmyFn-QYmUHP1hbDXESzshqLux4yQmF6Ocvg2XXwj8SVa9T-ra1tMsdg8bKEFEb8vmTlW7AekoUgO6hJZazEEaaPpzgWIWPky9AS0p0wbyYFEuiwbdYhhLlmx1_Lpcw3wU5y-9M7w9)
115+
-->
116+
![Development lifecycle with Git, containing Git commands add, commit, push, fetch, checkout, merge and pull](../fig/git-lifecycle.svg){: .image-with-shadow width="600px"}
98117
<p style="text-align: center;">
99-
Software development lifecycle with Git from <a href="https://www.pngwing.com/en/free-png-sazxf" target="_blank">PNGWing</a>
100-
{%comment%}<br>(licenced for non-commercial reuse){%endcomment%}
118+
Software development lifecycle with Git
101119
</p>
102120

103121
## Checking-in Changes to Our Project

fig/git-lifecycle.png

-225 KB
Binary file not shown.

0 commit comments

Comments
 (0)