---
# System prepended metadata

title: git simple tutorial

---

git simple tutorial
===
![An Introduction to Git: The Basics Every Beginning Developer Should Know](https://docs.ionos.space/git-workflow.jpeg)

Add ssh key to GitHub
---

> Now, password authentication is disabled by default. Therefore we use ssh key to authorize.

![](https://hackmd.io/_uploads/HJR2dMgy6.png)
```
$ ssh-keygen
$ cat .ssh/id_rsa.pub
```
![](https://hackmd.io/_uploads/HJAUKMgya.png)

Clone the repository to computer
---
![](https://hackmd.io/_uploads/HygQxHyy6.png)
```
$ git clone git@github.com:datastru/hw1-example-estherYJ.git
```

Do initial settings
---

```
$ git config --global user.email "you@example.com"
$ git config --global user.name "Your Name"
```

Push to git after compiling and test
---
```
$ git add src/hw1_p1-1.c
$ git commit
$ git push
```
* If there is an error during push. Do `$git pull --rebase` then push again.
    ![](https://hackmd.io/_uploads/rkoPyJI1T.png)
* The result would be shown on Github Actions after pushing.
    ![](https://hackmd.io/_uploads/ByhGkjEk6.png)
    ![](https://hackmd.io/_uploads/HyKgf4Byp.png)



### Additional Materials
[Git - Book](https://git-scm.com/book/zh-tw/v2)
[An Introduction to Git: The Basics Every Beginning Developer Should Know](https://docs.ionos.space/blog/git-intro/#the-git-workflow)

local build & test
---
project structure will be like
![](https://hackmd.io/_uploads/HkRhQOek6.png)

```
$ cd hw1-example-XXX
// gcc -O3 -std=c11 -Wall -c -o src/hw1_p1-1.o src/hw1_p1-1.c
// gcc -O3 -std=c11 -Wall -o output/hw1_p1-1.output src/hw1_p1-1.o
// ...
$ make

// input test from stdin and output to a file or stdout
$ output/hw1_p1-1.output < test/hw1_p1-1/input01.txt > result.txt

// compare with output file
$ diff -w result.txt test/hw1_p1-1/output01.txt

// remove result
$ rm result.txt

```