新增 remote
命令行操作
git remote add gitlab git://***/***.git
添加成功后旦事,查看本地remotes
git remote -v
gitlab? http://domain.com/project.git (fetch)
gitlab? http://domain.com/project.git (push)
origin? https://domain.com/project.git (fetch)
origin? https://domain.com/project.git (push)
通過SourceTree操作
2、push分支到指定的remote
git push [remote-name] [branch-name]第煮,如:
git push origin master
通過SourceTree操作
3示姿、修改原有分支的remote-name
原來已經(jīng)拉取的分支,如果執(zhí)行g(shù)it pull / git push,仍然會(huì)從 origin上 pull / push代虾。
可在項(xiàng)目根目錄 通過?vim .git/config 查看各分支的 remote-name情況。
可通過以下命令修改remote-name:
git branch branch_name --set-upstream-to your_new_remote/branch_name
示例:
git branch develop --set-upstream-to gitlab/develop
注意:需要新的remote上存在相應(yīng)的分支抒倚,才能修改褐着,否則報(bào)錯(cuò):error: the requested upstream branch 'gitlab/branch_name' does not exist⊥信唬可以通過以下兩種方式解決該問題:
a. 在gitlab界面上基于master創(chuàng)建一個(gè)相應(yīng)分支
b. 在本地push分支過去
4、查看分支配置
在項(xiàng)目根目錄執(zhí)行
vim .git/config