---
# System prepended metadata

title: Cloud Source Repositories 推拉
tags: [GCP]

---

---

title: Cloud Source Repositories 推拉

tags: GCP # 簡報的標籤

---
## PULL

點選source Repositories
![](https://i.imgur.com/PsRTBbq.png)

## 進入到倉庫內
![](https://i.imgur.com/xqIAUx0.png)

## 建立本機複本
切換至存放倉庫檔案的本機路徑
![](https://i.imgur.com/DkyEiVS.png)

將倉庫內的檔案拉取至本機(需安裝cloud SDK)
![](https://i.imgur.com/lgzphN9.png)

貼上複製連結
![](https://i.imgur.com/jzHumUJ.png)

# PUSH
將有變更的檔案推送至source Repositories
![](https://i.imgur.com/bMrlWIw.png)

## 將本地檔案推送到 Cloud Source Repositories
1. 使用終端機(需安裝cloud SDK)

2. Windows輸入指令

```
gcloud init && git config credential.helper gcloud.cmd
```
Linux 或 macOS輸入指令

```
gcloud init && git config credential.helper gcloud.sh
```
3. 將本地路徑添加至雲端推送路徑

```
git remote add google \
https://source.developers.google.com/p/[推送的專案ID]/r/[推送的倉庫]
```

4. 將此資料夾的所有變化提交至暫存區(需先切換至存放倉庫檔案的本機路徑)
```
git add .
```

5. 提交檔案
```
git commit -m "輸入修改版本說明"
```

6. 推送到 Cloud Source Repositories
```
git push --all google
```

[參考文件1](https://cloud.google.com/source-repositories/docs/pushing-code-from-a-repository#cloud-sdk)

[參考文件2](https://blog.csdn.net/A_Runner/article/details/79634640)