zoukankan      html  css  js  c++  java
  • 本地项目提交到gitlab

    第一步、项目目录下右键,选中 git bash here

    第二步,命令git init,目录下就会生成一个.git 目录

    ls -a 查看是否创建,可以看出创建完成

     

     第三步,命令 git add .  表示将当前目录下所有文件纳入git版本控制

     如果当前目录有多个文件,可以将 . 换成文件名指定文件

     第三步,命令提交:git commit -m "注释语句",提交到本地仓库

     第四步、在gitlab上新建一个项目,然后clone with HTTP,  地址https://gitlab.com/xxxx/xxx.git

    第五步、命令git remote add origin https://gitlab.com/xxxx/xxx.git 本地仓库和远程仓库关联

    第六部、命令 git push -u origin master 输入账号和密码即可

    最后注意,这时候提交代码的时候有可能不成功,这时候就需要执行以下命令

    命令 git pull https://gitlab.com/xxxx/xxx.git master --allow-unrelated-histories,

    注意--后面表示允许不相干的两个仓库合并,因为我们之前两个仓库是完全独立的,所以直接是没办法pull下来,需要加上后面参数才行

     注意有可能出现的问题

    1)fatal: remote origin already exists. 翻译过来就是:致命:远程来源已经存在

    git remote -v 查看远程库信息

    解决办法如下:
    1、先输入git remote rm origin(删除关联的origin的远程库)
    2、再输入git remote add origin https://gitlab.com/xxxx/xxx.git 就不会报错了!

    2)fatal: Couldn't find remote ref master  

    1、检查本地git配置 git config user.name、git config user.email

    2、git remote -v 查看是否有远程库,有就删掉 git remote rm origin

    3)fatal: 'origin' does not appear to be a git repository
    fatal: Could not read from remote repository.
    Please make sure you have the correct access rights
    and the repository exists.
    解决办法如下:
    git remote add origin https://gitlab.com/xxxx/xxx.git

     

     

  • 相关阅读:
    SQL Server 2005中的分区表(一):什么是分区表?为什么要用分区表?如何创建分区表?
    SQL Server 分区表
    SQL Server表分区
    Red Gate系列之一 SQL Compare 10.4.8.87 Edition 数据库比较工具 完全破解+使用教程
    C# WinForm开发系列
    C# WinForm开发系列
    富文本编辑器 CKeditor 配置使用
    C# ListView用法详解
    C# WinForm给Button或其它控件添加快捷键响应
    WebApi安全性 使用TOKEN+签名验证
  • 原文地址:https://www.cnblogs.com/flyToDreamJava/p/14583100.html
Copyright © 2011-2022 走看看