1 . git init //初始化仓库,在初始化的目录中会出现.git的文件夹

2. git add .(文件name) //添加文件到本地仓
 
3. git commit -m "first commit" //添加文件描述信息,越详细越好
 
4. git remote add origin + 远程仓库地址 //链接远程仓库,创建主分支
 
5. git push -u origin master //把本地仓库的master的文件推送到远程仓库
提交之后输入用户名密码后就会出现以下错误
To https://gitee.com/lulin-oldboy/devops.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'url'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

想解决以上错误,只需要在4,5之间使用git pull origin master即可

1. git init //初始化仓库
2. git add .(文件name) //添加文件到本地仓库
3. git commit -m "first commit" //添加文件描述信息越详细越好
4. git remote add origin + 远程仓库地址 //链接远程仓库,创建主分支
5. git pull origin master // 把本地仓库的变化连接到远程仓库主分支
git 出现 fatal: refusing to merge unrelated histories 错误

git pull origin master --allow-unrelated-histories

6. git push -u origin master //把本地仓库的文件推送到远程仓库

问题解决,可以正常使用git了

git 新建仓库第一次提交的更多相关文章

  1. [Git & GitHub] 利用Git Bash进行第一次提交文件

    转载:https://blog.csdn.net/dietime1943/article/details/72420042 利用Git Bash进行第一次提交文件 快下班的时候,MD群里有人问怎么向g ...

  2. git新建仓库

    克隆地址 git clone https://git.oschina.net/dy09/dy_shop.git 在克隆下来的文件夹里面进行下面的操作1.git add -A 2.git commit ...

  3. git远程仓库、提交代码操作

    初始化仓库 1.初始化 git init #或 git clone 远程仓库地址 git init 后续要添加远程仓库,git clone不需要再添加 2.连接仓库 git remote add 远程 ...

  4. Git 新建文件并提交

    1.创建一个readme.txt. cd /home/cyp/learngit touch readme.txt vim readme.txt 编写内容, wq 保存推出 2.提交步骤 2.1  gi ...

  5. git安装和第一次提交过程

    1,新建文件夹test,运行命令 git init 2,找到test的.git文件夹,打开之后找到config文件,在最后边加上一句话 [user] email=your email name=you ...

  6. git学习(3)----git 新建分支并提交本地代码到远程分支

    一.步骤 1.在gitlab上创建一个issue,issue一般来说是版本发布说明.比如本次更新了什么功能,修复了什么bug什么的. 2.然后在本地创建一个branch,或者直接在gitlab上申请m ...

  7. git新建分支及提交代码到分支

    二.创建分支并提交代码到分支 上述添加成员的方式非常简单,但是如果说每一个小组成员都可以对仓库push内容,就涉及到一个代码的安全和冲突问题了,当多个成员同时在线编辑时容易出现冲突,假设A的代码是有问 ...

  8. git 新建仓库

    rm -rf .git git init git add . git commit -m "Initial commit" git remote add origin <gi ...

  9. 2017.6.30 使用git新建项目、仓库并拉取、提交代码

    1.在码云上新建一个项目rms 2.在本地指定位置新建仓库,生成.git文件夹 3.同步远程仓库,并拉取最新代码 远程仓库默认名为orgin.可以修改,这里就是用默认名了. 注意:这里使用ssh方式的 ...

随机推荐

  1. Ubuntu 文件和目录常用命令

    目标 查看目录内容 ls 切换目录 cd 创建和删除操作 touch rm mkdir 拷贝和移动文件 cp mv 查看文件内容 cat more grep 其他 echo 重定向 > 和 &g ...

  2. 全排列 递归方法(permutation原理

    https://blog.csdn.net/axiqia/article/details/50967863  原博客 (一)递归的全排列算法 (A.B.C.D)的全排列为 1.A后面跟(B.C.D)的 ...

  3. zencart随机获取一张产品图片及价格小程序

    <?php //header("content-Type: text/html; charset=utf-8"); //@set_time_limit(1800); //@i ...

  4. We're sorry but mobile doesn't work properly without JavaScript enabled. Please enable it to continue.

    vue过程中遇见这个问题:We're sorry but mobile doesn't work properly without JavaScript enabled. Please enable ...

  5. K-D树

    一般用来解决各种二维平面的点对统计,也许一般非正解? 没时间慢慢写了,打完这个赛季后补细节 建树板子: #include <cstdio> #include <locale> ...

  6. 根据IP获取经纬度 js

    <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> &l ...

  7. springboot mybatis 的SQL异常不输出错误到控制台问题排查

    项目中使用springboot集成 mybatis,运行过程中查询SQL列在表中不存在,但系统不输出任何错误到控制台 但SQL是打印的,只是没有任何异常信息 将SQL复制出来到数据库中运行,才发现错误 ...

  8. 前端知识体系:JavaScript基础-作用域和闭包-词法作用域和动态作用域

    词法作用域和动态作用域 1.作用域: 作用域是指程序代码中定义变量的区域 JavaScript采用词法作用域,也就是静态作用域 2.词法作用域和动态作用域 因为JavaScript采用的是词法作用域, ...

  9. resize([[data],fn]) 当调整浏览器窗口的大小时,发生 resize 事件。

    resize([[data],fn]) 概述 当调整浏览器窗口的大小时,发生 resize 事件.   参数 fnFunctionV1.0 在每一个匹配元素的resize事件中绑定的处理函数.直线电机 ...

  10. UVA1674 闪电的能量 树剖

    UVA1674 闪电的能量 树剖 题面 水.树剖模板 #include <cstdio> #include <cstring> #include <algorithm&g ...