git 使用案例(本地仓库无缝迁移远程仓库)
之前都是直接从gitlab上clone代码,然后把本地代码copy过去,然后push。有点麻烦,查询了一下如何无缝从本地仓库迁移到远程仓库。记录一波...
下面的例子采用github来做例子。
1. 在本地项目目下,创建本地仓库。
cd test // 进入项目根目录
git init // 初始化仓库
2. 提交代码到本地仓库
git add *
git commit -m "project init..."
3. 添加远程仓库
git remote add origin https://github.com/chenkaiyin1201/null.git
git remote -v // 可以查看一下当前项目链接的远程仓库地址
4. push本地仓库到远程仓库
git push origin master
备注:
如果出现报错
To https://github.com/chenkaiyin1201/null.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/chenkaiyin1201/null.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushin
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.
执行: git push -f 即可。
git 使用案例(本地仓库无缝迁移远程仓库)的更多相关文章
- Git——如何将本地项目提交至远程仓库(第一次)
1.(先进入项目文件夹)通过命令 git init 把这个目录变成git可以管理的仓库. git init 2.把文件添加到版本库中,使用命令 git add .添加到暂存区里面去,不要忘记后面的小数 ...
- Git——如何将本地项目提交至远程仓库
参考文章:http://blog.csdn.net/dadaxiongdebaobao/article/details/52081826 git 将一个本地文件目录提交到远程仓库的步骤 参考文章: ...
- 【开发工具 - Git】之本地项目托管到远程仓库
这里所说的“本地项目托管到远程仓库”,说的是:例如,我们在本地有一个写了很长时间的项目,现在想要托管到GitHub或码云上进行版本控制. 这个过程大致需要以下几个步骤: (1)在本地初始化Git项目本 ...
- Git实现从本地添加项目到远程仓库
Git是现在最流行的版本控制系统之一了,今天也试试了,成功了上传了远程仓库,接下来看看我是怎么做的. (ps:七牛抓取不到图片,请移步:http://blog.csdn.net/u011043843/ ...
- 【转】 Git——如何将本地项目提交至远程仓库
1.(先进入项目文件夹)通过命令 git init 把这个目录变成git可以管理的仓库 git init 2.把文件添加到版本库中,使用命令 git add .添加到暂存区里面去,不要忘记后面的小数点 ...
- git删除了本地文件,从远程仓库中恢复
在本地删除了文件,使用git pull,无法从远程项目中拉取下来 具体操作 查看项目的状态,会显示出你删除的数据 git status 进入被删除的文件的目录下,假设删除的文件名为 test.txt ...
- git 快速使用(本地仓库同步到远程仓库)
学git一段时间,可惜公司用的是svn,平时少用,又忘了,总结一下,免得下次又得重新学习.得多多用才是正道! 一. 将本地的提交到网上git仓库 1.在git创建仓库 ...
- git本地仓库与github远程仓库链接协议问题
前提条件:有github账号,本地安装了git,能上网. 环境:ubuntu14.0.4LTS 首先在你得在github上创建一个仓库new repository,然后再本地创建一个文件夹mkdir ...
- 使用git把本地目录传到远程仓库
需求: 要把本地不为空的一个目录和远程现有的一个仓库关联 步骤如下: git init //生成.git目录 git add . //把当前目录里的文件加入到暂存区 git commit -m '上传 ...
随机推荐
- !vtop 命令
这命令超级牛B ,用途是算内存所在屋里地址 !vtop 命令可以有两个参数,第一个参数是CR3 寄存器的值,第二个参数是要查询的虚拟地址是多少,比如 kd> !vtop 19001e0 7c80 ...
- 异步action和redux-thunk理解
异步action一般指的就是异步action创建函数 action创建函数分为同步action创建函数和异步action创建函数 同步action创建函数(最常见的): function reques ...
- 2018-10-31-WPF-在触摸线程等待主线程窗口关闭会让主线程和触摸线程相互等待
title author date CreateTime categories WPF 在触摸线程等待主线程窗口关闭会让主线程和触摸线程相互等待 lindexi 2018-10-31 9:30:9 + ...
- Arrays 001
1.1 Array Initalization First of all, we need know Java arrays is static. When the array is initiali ...
- scip 练习2.20
(define (same-parity x . z) (define (q? y) (= (remainder y ) )) (define (o? y) (= (remainder y ) )) ...
- jq-demo-2种吸顶效果
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- springcloud -zuul(1-zuul的简单使用)
1.maven引入包 <dependency> <groupId>org.springframework.cloud</groupId> <artifactI ...
- Batch - call, start, goto 区别
参考(待整理): 批处理命令——call 和 start
- delphi xe10 文件目录/路径操作 (Andorid、ios)
//获取临时文件路径(支持安卓.IOS) function GeFileName(const AFileName: string): string; begin {$IFDEF ANDROID} Re ...
- kafka和flume进行整合的日志采集的confi文件编写
配置flume.conf 为我们的source channel sink起名 a1.sources = r1 a1.channels = c1 a1.sinks = k1 指定我们的source收集到 ...