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. linux环境安装docker,部署应用

    安装: 1.Docker要求CentOS系统的内核版本高于 3.10 ,通过 uname -r 命令查看你当前的内核版本是否支持安账docker 2.更新yum包:sudo yum update 3. ...

  2. EF方式增、删、改、查(基本使用)

    右击项目——添加——新建项——数据(C#)——选择ADO.NET实体数据模型——点击添加——然后根据实体数据模型向导来一步步的做. 用到的表 using System; using System.Da ...

  3. 完整的ELK+filebeat+kafka笔记

    之前有写过elasticsearch集群和elk集群的博客, 都是基于docker的,使用docker-compose进行编排(K8S暂未掌握) 三台服务器搭建es集群:https://www.cnb ...

  4. Vue 一些用法

    v-model : 数据绑定(多数用于表单元素) ps:同时v-model支持双向数据绑定v-for : 用于元素遍历v-on:事件名称=“方法名” (事件绑定)ps: methods:用于绑定 v- ...

  5. Centos杀死进程kill方法大全

    杀死进程最安全的方法是单纯使用kill命令. 首先使用ps -ef命令确定要杀死进程的PID,然后输入以下命令: # kill -pid 注释:标准的kill命令通常都能达到目的.终止有问题的进程,并 ...

  6. Codeforces 1179 D - Fedor Runs for President

    D - Fedor Runs for President 思路: 推出斜率优化公式后,会发现最优点只可能来自凸斜率中的第一个元素和最后一个元素, 这两个元素不用维护凸斜率也能知道,就是第一个和上一个元 ...

  7. selenium 操作多个窗口间切换

    #coding=gbk ''' selenium多个窗口间切换 ''' from selenium import webdriver as wd from selenium.webdriver imp ...

  8. [2019HDU多校第三场][HDU 6603][A. Azshara's deep sea]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6603 题目大意:给出一个凸包,凸包内有若干个圆,要求画尽可能多的对角线使得他们两两不在凸包内相交且不与 ...

  9. Codeforces Round #584 B. Koala and Lights

    链接: https://codeforces.com/contest/1209/problem/B 题意: It is a holiday season, and Koala is decoratin ...

  10. Codeforces Round #585 (Div. 2) A. Yellow Cards(数学)

    链接: https://codeforces.com/contest/1215/problem/A 题意: The final match of the Berland Football Cup ha ...