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: topics/git/README.md
+26-15Lines changed: 26 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,21 +14,27 @@
14
14
15
15
<details>
16
16
<summary>How do you know if a certain directory is a git repository?</summary><br><b>
17
-
18
17
You can check if there is a ".git" directory.
19
-
</b></details>
18
+
</b>
19
+
</details>
20
20
21
21
<details>
22
-
<summary>Explain the following: <code>git directory</code>, <code>working directory</code> and <code>staging area</code></summary><br><b>
22
+
<summary>Explain the following: <code>git directory</code>, <code>working directory</code> and <code>staging area</code></summary><br>
23
+
<b>
23
24
24
25
This answer taken from [git-scm.com](https://git-scm.com/book/en/v1/Getting-Started-Git-Basics#_the_three_states)
25
26
26
-
"The Git directory is where Git stores the meta data and object database for your project. This is the most important part of Git, and it is what is copied when you clone a repository from another computer.
27
+
"The Git directory is where Git stores the meta-data and object database for your project. This is the most important
28
+
part of Git, and it is what is copied when you clone a repository from another computer.
27
29
28
-
The working directory is a single checkout of one version of the project. These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify.
30
+
The working directory is a single checkout of one version of the project. These files are pulled out of the compressed
31
+
database in the Git directory and placed on disk for you to use or modify.
29
32
30
-
The staging area is a simple file, generally contained in your Git directory, that stores information about what will go into your next commit. It’s sometimes referred to as the index, but it’s becoming standard to refer to it as the staging area."
31
-
</b></details>
33
+
The staging area is a simple file, generally contained in your Git directory, that stores information about what will go
34
+
into your next commit. It’s sometimes referred to as the index, but it’s becoming standard to refer to it as the staging
35
+
area."
36
+
</b>
37
+
</details>
32
38
33
39
<details>
34
40
<summary>What is the difference between <code>git pull</code> and <code>git fetch</code>?</summary><br><b>
@@ -46,20 +52,22 @@ a separate branch in your local repository
46
52
<summary>How to check if a file is tracked and if not, then track it?</summary><br><b>
47
53
48
54
There are different ways to check whether a file is tracked or not:
49
-
50
-
-`git ls-files <file>` -> exit code of 0 means it's tracked
51
-
-`git blame <file>`
55
+
-`git ls-files <file>` -> exit code of 0 means it's tracked
56
+
-`git blame <file>`
52
57
...
53
-
</b></details>
58
+
</b>
59
+
</details>
54
60
55
61
<details>
56
62
<summary>Explain what the file <code>gitignore</code> is used for</summary><br><b>
57
-
</b></details>
63
+
The purpose of <code>gitignore</code> files is to ensure that certain files not tracked by Git remain untracked. To stop tracking a file that is currently tracked, use git rm --cached.
64
+
</b>
65
+
</details>
58
66
59
67
<details>
60
68
<summary>How can you see which changes have done before committing them?</summary><br><b>
61
-
62
69
`git diff`
70
+
63
71
</b></details>
64
72
65
73
<details>
@@ -72,7 +80,8 @@ There are different ways to check whether a file is tracked or not:
72
80
<summary>You've created new files in your repository. How to make sure Git tracks them?</summary><br><b>
73
81
74
82
`git add FILES`
75
-
</b></details>
83
+
</b>
84
+
</details>
76
85
77
86
### Scenarios
78
87
@@ -130,13 +139,14 @@ True
130
139
131
140
<details>
132
141
<summary>You have two branches - main and devel. How do you make sure devel is in sync with main?</summary><br><b>
133
-
142
+
<code>
134
143
```
135
144
git checkout main
136
145
git pull
137
146
git checkout devel
138
147
git merge main
139
148
```
149
+
</code>
140
150
141
151
</b></details>
142
152
@@ -237,6 +247,7 @@ Using the `git rebase` command
237
247
<details>
238
248
<summary>In what situations are you using <code>git rebase</code>?</summary><br><b>
239
249
Suppose a team is working on a `feature` branch that is coming from the `main` branch of the repo. At a point, where the feature development is done, and finally we wish to merge the feature branch into the main branch without keeping the history of the commits made in the feature branch, a `git rebase` will be helpful.
0 commit comments