# Git
###### tags: `linux2020` `Git`
## How to use Git in 10 minutes
1. Install Git in your computer.
```
$ sudo apt-get install git
$ git --version
```
2. Create or enter your working directory.
```
$ mkdir homework
$ cd homework
```
3. Initial Git in your working directory.
```
$ git init
```
4. Setting your info.
```
$ git config --global user.name "12101210cc"
$ git config --global user.email "example@mail"
```
5. Now, you should check your status.
```
$ git status
```
The file name in color **RED** means your code still **not add to STAGING AREA**, and color **GREEN** means your file already add to staging area.
```graphviz
digraph graphname {
W [label="Working directory" fontcolor=red]
S [label="Staging Area" fontcolor=darkgreen]
R [label="Repository" fontcolor=blue]
G [label="Remote Server (e.g. GitHub)" fontcolor=purple]
W->S [label=" git add"]
S->R [label=" git commit"]
R->G [label=" git push"]
}
```
6. Add your file into staging area and check status.
```
$ git add test.c
$ git status
```
7. Commit it if there is no problem with your file and check the status again, it will show you a branch information.
```
$ git commit
$ git status
```
8. Set your remote server. Copy your remote server (e.g. GitHub, GitLab) project link then add it and check it.
```
$ git remote add origin https://github.com/12101210cc/example
$ git remote -v
```
9. Before you push, you need to pull your code first. Generally, you have to update your local code (project) from remote server. (e.g. GitHub, GitLab)
```
$ git pull origin master
```
10. Push your code to the remote server. (e.g. GitHub, GitLab)
```
$ git push origin master
```
## How to use Git in detail
### Setting personal config
```
$ git config --global <command> <argc>
```
[Reference](https://youtu.be/LZ4oOzZwgrk)
### Pull and push
updating...
### Ignore
updating...
---
>[name=Huang Yu Hsuan] [time=Mon, Feb 24, 2020][color=darkgreen]