zoukankan      html  css  js  c++  java
  • 【在家办公】代码上传公司远端GitLab仓库

    【在家办公】代码上传公司远端GitLab仓库


    查看本地的git 如何添加远程仓库

    1.查看远程仓库地址

    git remote -v
    

    此时若什么都没有显示说明,git无远程仓库。


    2.添加ssh协议的远程仓库

     git remote add origin git@github.com:**********.git
    

    再次查看,即可查看到2个远程仓库的链接

    origin	git@gitlab.com:**********.git (fetch)
    origin	git@gitlab.com::**********.git (push)
    

    当前,我本机就是用的这种方式连接的github,好处是每次提交代码时,不需要重复来回输入用户名和密码,这就是ssh秘钥的好处。


    使用家里的WiFi长传到github上的代码时,报出如下错误:

    $ git push origin 分支名称
    ssh: connect to host github.com port 22: Connection refused
    fatal: Could not read from remote repository.
    

    得知第一种协议被禁掉后,只能换一种连接进行合并本地仓库了。继续往下看另一种协议。


    3.切换成 https协议连接github

    建立本地仓库和远端GitLab仓库的关联关系

    git remote add origin  https://gitlab*********************.git
    

    在这一步时如果出现错误:fatal:remote origin already exists先清除一下关联关系:

    git remote rm origin
    

    再重新关联:

    git remote add origin  https://gitlab*********************.git
    

    检查关联是否已建立且正确

    git remote -v
    

    注意:因为我们是在家办公,我们公司的gitlab域名映射成了ip我们直接把`域名换成IP地址`
    # 添加http链接协议
    git remote add origin http://ip:port/*********************.git
    

    参考链接:https://blog.csdn.net/s740556472/article/details/80318886

    https://www.jianshu.com/p/c74ae40b5127

    从小白到大神的蜕变~~
  • 相关阅读:
    CentOS7的内核优化
    centos7 系统优化脚本
    Centos7之系统优化
    Jenkins安装
    Zabbix安装
    Systemd 入门教程:命令篇
    开源ERP系统Odoo搭建文档
    SSH详解
    使用pm2来保证Spring Boot应用稳定运行
    npm安装与使用
  • 原文地址:https://www.cnblogs.com/tjw-bk/p/14686027.html
Copyright © 2011-2022 走看看