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 '上传 ...
随机推荐
- 三.Python数据类型详述
Python第三节数据类型详述 一.多变量赋值 python允许多变量赋值 多变量赋相同的值a = b = c = 1 多变量赋不同的值a, b, c = 1, 2, "fuckyou&qu ...
- Linux 父进程发送信号杀死子进程
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <signal. ...
- tomcat nio apr
NIO[root@localhost ~]# vim /usr/local/tomcat9/conf/server.xml<Connector port="8080" pro ...
- 百度网盘Mac版如何分享链接?创建百度网盘 for Mac分享链接的方法
想把自己百度网盘里的数据分享给朋友,该怎么操作呢?有很多朋友使用百度网盘,可以很轻松的自己的文件上传到网盘上,并可跨终端随时随地查看和分享.下面Mac down小编就给大家介绍一下创建百度网盘 for ...
- 配置类一@Configuration
import org.springframework.context.annotation.Configuration; @Configuration用于定义配置类,可替换xml配置文件,被注解的类内 ...
- Android NDK Downloads
https://developer.android.google.cn/ndk/downloads/index.html
- PHP PDO 大对象 (LOBs)
应用程序在某一时刻,可能需要在数据库中存储"大"数据. "大"通常意味着"大约 4kb 或以上",尽管某些数据库在数据达到"大&q ...
- NOIp2018集训test-9-5(am)
Problem A. maze 递归处理,题解写得真简单. 我大概这辈子也写不出来这种东西吧. Problem B. count 容易发现合法的数中一定有且仅有两个数加起来等于10,其他数两两配对加起 ...
- NX二次开发-UFUN关闭STL文件函数UF_STD_close_stl_file
NX9+VS2012 #include <uf.h> #include <uf_obj.h> #include <uf_modl.h> #include <u ...
- HDU1501-Zipper-字符串的dfs
Given three strings, you are to determine whether the third string can be formed by combining the ch ...