---
# System prepended metadata

title: Git 簡易流程

---

# Git 簡易流程

- using CLI

### Check Git Version
```
git --version
```
---
### 建立與 BitBucket 的 SSH Key
1. Generate an SSH Key with Email (if you don't have one):
```
ls -al ~/.ssh
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
ssh-add ~/.ssh/id_rsa
```
2. Add the SSH Key to Bitbucket
- 將印出的這一段貼進Bitbucket
```
cat ~/.ssh/id_rsa.pub
```
- Go to your Bitbucket account and navigate to Personal settings.
- Select SSH keys under Security.
- Click Add key and paste your SSH public key into the Key field. Give it a label and click Save.
3. Verify the SSH Connection to Bitbucket
```
ssh -T git@bitbucket.org
```
- You should see a message like
```
authenticated via ssh key.
You can use git to connect to Bitbucket. Shell access is disabled.
```
---
### 建立repository並完成push
1. Create repository on BitBucket 
2. Clone the repository into your local machine
- 成功clone會出現一個repository資料夾
```
git clone git@bitbucket.org:username/repository.git
```
3. Adding a file to your Bitbucket repository
- 把所有要上傳Git的檔案移動進repository資料夾!!!
4. Stage the files for the syncing process by adding them to Git with the following command.
```
git add .
```
5. Check progress
```
git status
```
6. Add git commit
```
git commit -m "first commit"
```
7. push
```
git push origin master(branch name)
```