# Introduction to Git
###### tags: `tutorial` `electrical_system` `NTURT`
##### Author: @QuantumSpawner
## Why using git
Developing software by a single person is already hard enough, and it's even more difficult with multiple persons. That's why we need version control to centralize the development of our software.
Git, which is developed by the creater of linux, Linus Torvalds, is the most used tool for version control in software development. In fact, the widely known website [Github](https://github.com/) (that is said to contain every solution of human problem) is build on it.
In NTURT, we also heavily rely on git to develop our software, you may also chcekout our github repositories if you like: [NTURacingTeam](https://github.com/NTURacingTeam). So it's mandatory to master git before joining us.
## Using git
Please checkout:
- How does git works: [How Does Git Work?](https://phoenixnap.com/kb/how-git-works)
- Some of most used git commands: [10 Git Commands](https://www.freecodecamp.org/news/10-important-git-commands-that-every-developer-should-know/)
## How to submit your homework
Since all programs in NTURT are managed by git repositories, please push your program homeworks onto your github repository when you see
:::success
Please push your homework onto your github repository in the `HOMEWORK` directory.
:::
in `homework`/`topic` sections of other tutorials.
For example in this homework
:::success
Please push your homework onto your github repository in the `git` directory.
:::
The hierarchy of your github repository should look something like this:
```
.
├── [README.md]
├── git
│ └── your git homework
├── ros
│ └── your ros homework
└── ...
```
:::info
Note: `README.md` is optional here, but highly recommended as an introduction to your work. `README.md` is usually used to include some useful information about your work, including how to setup and how to use your code.
:::
Please set your github repository where you keep your homework public and upload the github url(uniform resource locator or site address) to [NTUCOOL](https://cool.ntu.edu.tw/courses/7119/assignments/96866).
We will clone from it at **September 17, 2023, 23:59 CST**, so future pushes to the repository will not be graded.
## Git homework
:::success
Please push your homework onto your github repository in the `git` directory.
:::
Please clone from the repository by:
```bash=
git clone https://github.com/NTURacingTeam/git_homework
```
and then create a xml file `git.xml` containing the keys form each of the tasks as
```xml=
<!-- git.xml -->
<?xml version="1.0" encoding="utf-8"?>
<git>
<task1>
TASK_KEY1
</task1>
<task2>
TASK_KEY2
</task2>
<task3>
TASK_KEY3
</task3>
<task4>
<line0>
TASK4_LINE0_KEY
</line0>
<line1>
TASK4_LINE1_KEY
</line1>
<line2>
TASK4_LINE2_KEY
</line2>
<line3>
TASK4_LINE3_KEY
</line3>
</task4>
</git>
```
then push it to your repository. You can find the keys in the files illustrated below.
:::info
Note: cloning the repository by
```bash=
git clone https://github.com/NTURacingTeam/git_homework
```
will by befault only clone `master` branch. In order to finish this homework, you would also need other branches, please find a way to clone them too.
:::
:::info
XML (E**x**tensible **M**arkup **L**anguage) is a markup language usually used in C/C++ to be used as configuration file. But here we only use it like an answer sheet that contains "keys".
:::
### Task1
The key is in the file `key` of the branch `main`. Replace TASK_KEY1 to the key you found.
### Task2
The key is in the file `key` of the branch `KEY`. Replace TASK_KEY2 to the key you found.
### Task3
The key is in the file `key` of the previous commit of `master`. Replace TASK_KEY3 to the key you found.
### Task4
There is a merging issue in the branch `MERGE1` and `MERGE2` for `task4.yaml`, please find out which change to keep before merging, then repalce TASK4_LINE0_KEY to TASK4_LINE3_KEY with correct keys.
:::info
Hint: VS code is particularly useful here since it has built in support for git operations such as dealing with merge conflict.
:::
:::info
Hint: Or if you are familiar with github, you may be able to finish this homework just by clicking some buttons on github.
:::