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: lessons/git-commit.md
+13-8Lines changed: 13 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,11 +21,11 @@ You can think of a commit as a _snapshot_ of the instance of the codebase at a g
21
21
22
22
Internally, Git tracks these commits by creating an [Directed Acyclic Graph (DAG)](https://en.wikipedia.org/wiki/Directed_acyclic_graph), with every commit representing a node in the graph and every edge points back to the previous commit that occurred.
1. Working directory: where your codebase actually resides
41
41
2. Staging area: set of files that you want to include in a snapshot
42
42
3. Repository: local/remote repository storing metadata about the project and Git
43
43
44
44
By default, all of your files reside in the working directory and are not yet added to the staging area. If you want a file included in the staging area, then you must first add it to the staging area (we will cover how this happens later on).
45
45
46
-
:::callout{.info}
46
+
:::callout{.info.minimal}
47
47
There are also ways to remove files from the staging area!
48
48
:::
49
49
@@ -59,12 +59,17 @@ Create a new file in the folder and add some text to it.
59
59
echo'Hello world'>> hello.txt
60
60
```
61
61
62
-
:::callout{.info}
62
+
:::callout{.info.minimal}
63
63
The command above essentially redirects the output of the `echo` (Hello world) into a new file `hello.txt`
64
64
:::
65
65
66
66
If you don't want to use bash commands, you can just create the file using your preferred method as well.
Now, run the following command to view the status of your repository.
@@ -89,7 +94,7 @@ nothing added to commit but untracked files present (use "git add" to track)
89
94
90
95
Recall that in [Adding files to a snapshot](./#adding-files-to-a-snapshot"mention"), Git does not automatically add files to a snapshot as it does not know exactly what you want. So we want to tell Git that we want `hello.txt` in the snapshot.
91
96
92
-
:::callout{.info}
97
+
:::callout{.info.minimal}
93
98
`git status` is to view the state of your repository in Git's eyes. Use it to view things like the current files in the snapshot.
94
99
95
100
You may find exercises for it [here](https://github.com/git-mastery/problems-directory?tab=readme-ov-file#git-status).
@@ -107,7 +112,7 @@ As discussed in [What is a commit](./#what-is-a-commit "mention"), a file from t
107
112
108
113
To add `hello.txt` to the staging area, use the following command:
109
114
110
-
:::callout{.warning}
115
+
:::callout{.warning.minimal}
111
116
We will be covering what `git add` does in a later lesson.
112
117
:::
113
118
@@ -143,6 +148,6 @@ git commit -m "First commit"
143
148
144
149
The `-m` flag is used to specify the commit message. Every commit has an accompanying message that you can use to indicate what the commit contains/entails.
145
150
146
-
:::callout{.info}
151
+
:::callout{.info.minimal}
147
152
If you do not use `-m`, your favorite terminal/GUI editor will be launched and you can compose the commit message in that editor, save it, and close the editor
0 commit comments