美文网首页
git 切换remote

git 切换remote

作者: 亮声 | 来源:发表于2017-04-01 15:28 被阅读0次

新增 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

原来已经拉取的分支,如果执行git pull / git push,仍然会从 origin上 pull / push。

可在项目根目录 通过 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上存在相应的分支,才能修改,否则报错:error: the requested upstream branch 'gitlab/branch_name' does not exist。可以通过以下两种方式解决该问题:

a. 在gitlab界面上基于master创建一个相应分支

b. 在本地push分支过去

4、查看分支配置

在项目根目录执行

vim .git/config

相关文章

  • 常见 Git 命令(持续记录)

    仓库相关 查看远程仓库地址:git remote -v 切换远程仓库地址:直接切换:git remote set-...

  • git

    切换git仓库地址git remote set-url origin url

  • git 切换remote

    新增 remote 命令行操作 git remote add gitlab git://***/***.git 添...

  • git

    切换远程仓库git remote rm origingit remote add origin url 新建仓库并...

  • git使用ssh或者http方式pull和push代码

    切换成http方式:git remote set-url origin http://git.haohuoduo....

  • git9~github切换到ssh.md

    2022.08.10 github切换到ssh git remote -v 查看远程连接的方式 git remot...

  • Mac Homebrew 更换中国源

    Homebrew安装主要靠git仓库,切换源实际上就是切换相关git repo的remote url. 具体做法:...

  • Git 基本命令笔记

    切换远程仓库的连接 git remote set-url origin URL 修改 config 文件,登陆git

  • git相关的命令

    新建并切换分支git checkout -b bugfix 查看远程仓库 git remote 本地仓库推至远...

  • git 命令snippets

    在本地切换远程分支git checkout -b local_branch_name remote\origin\...

网友评论

      本文标题:git 切换remote

      本文链接:https://www.haomeiwen.com/subject/onviottx.html