You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _episodes/14-collaboration-using-git.md
+33-15Lines changed: 33 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,11 +57,11 @@ Git has several important characteristics:
57
57
so even if you make a mistake you can revert to a point before it.
58
58
59
59
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,
62
62
such as:
63
63
-**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
65
65
and where you are currently working.
66
66
It is also known as the “untracked” area of Git.
67
67
Any changes to files will be marked by Git in the working directory.
@@ -72,32 +72,50 @@ such as:
72
72
-**staging area (index)** -
73
73
once you tell Git to start tracking changes to files
74
74
(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.
76
76
Each subsequent change to the same file needs to be followed by another `git add filename` command
77
77
to tell Git to update it in the staging area.
78
78
To see what is in your working directory and staging area at any moment
79
79
(i.e. what changes is Git tracking),
80
80
run the command `git status`.
81
81
-**local repository** -
82
-
stored within the `.git` directory of your project,
82
+
stored within the `.git` directory of your project locally,
83
83
this is where Git wraps together all your changes from the staging area
84
84
and puts them using the `git commit` command.
85
85
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.
87
87
-**remote repository** -
88
88
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).
90
90
While your project is nicely version-controlled in your local repository,
91
91
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
-
{: .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)
0 commit comments