# gitHub

mkdir mypython

第一隻程式:hello.py

```python
# -*- coding: utf-8 -*-
#這是向世界打招呼
print("hello world")
```

### 使用github

#### Step 1: Create a local git repository&#x20;

cd mypython

```
git init
```

#### Step 2: Add a new file to the repo

```
mv ~/hello.py .
git status
```

![](https://529150212-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lh81JtaIQ84bwQqz_Wh%2F-LwW6MyUefOjl8P6HPO5%2F-LwW9eWnMrA5Fqg53zAG%2Fimage.png?alt=media\&token=572e5881-bfb1-407f-9891-2a1430d53bb2)

#### Step 3: Add a file to the staging environment

```
git add .
git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

	new file:   hello.py
```

#### Step 4: Create a commit

```
git commit -m "This is my first python!"
*** Please tell me who you are.

Run

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

to set your account's default identity.
Omit --global to set the identity only in this repository.

```

```
git config --global user.email "kawsing@gmail.com"
git config --global user.name "kawsing"
```

#### Create a new repository on GitHub

![](https://529150212-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lh81JtaIQ84bwQqz_Wh%2F-LwW6MyUefOjl8P6HPO5%2F-LwWAVztz5aH8WoCCLSZ%2Fimage.png?alt=media\&token=33beecba-3ee0-4e25-b35d-fd2203300f17)

#### push an existing repository from the command line

```
git remote add origin https://github.com/kawsing/mypython.git
git push -u origin master
```

![](https://529150212-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lh81JtaIQ84bwQqz_Wh%2F-LwW6MyUefOjl8P6HPO5%2F-LwWAeZvrAd2-GADNn7U%2Fimage.png?alt=media\&token=5e0b8f73-4a0d-499a-8197-d7d5fe42fbde)

![](https://529150212-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lh81JtaIQ84bwQqz_Wh%2F-LwW6MyUefOjl8P6HPO5%2F-LwWAj-AsNgzr2Pb1QeU%2Fimage.png?alt=media\&token=47cdd9b2-f142-413a-9c7e-22501ce4da2a)
