2013-02-24

Git Remote

要跟遠端搭上線有兩種作法:
  • 使用 git clone 從遠端複製既有的專案到本機
  • 使用 git remote add 與 git push 將本機的專案送到遠端

使用 git clone
> git clone https://cw1057@bitbucket.org/cw1057/test.git bproject.git

Cloning into 'bproject.git'...
Password for 'https://cw1057@bitbucket.org':
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.

使用 git remote add 與 git push
> git remote

> git remote add origin https://cw1057@bitbucket.org/cw1057/test.git
> git remote
origin
> git push -u origin --all
Password for 'https://cw1057@bitbucket.org':
Counting objects: 3, done.
Writing objects: 100% (3/3), 206 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: bb/acl: cw1057 is allowed. accepted payload.
To https://cw1057@bitbucket.org/cw1057/test.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.
使用 git remote add 之後,若遠端有檔案,得在執行 git push 之前,先執行 git pull 將遠端的檔案拉下來,不然  git push 是會失敗的。

重新命名遠端
> git remote
origin

> git remote rename origin neil

> git remote
neil

斷線
> git remote
origin

> git remote rm origin

> git remote


回到 Git 學習筆記
---
---
---

沒有留言:

張貼留言