Git如何将建立在本地的仓库上传到Gitee中

发布时间:2020-11-09 15:34:17 作者:Leah
来源:亿速云 阅读:222

今天就跟大家聊聊有关Git如何将建立在本地的仓库上传到Gitee中,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

电脑安装git客户端、注册github账号并登陆

到本地项目文件夹右键选择git bash here

Git如何将建立在本地的仓库上传到Gitee中

输入个人信息(代码提交者)

git config --global user.name "xxxx" 

git config --global user.email xxxxx@qq.com 

Git如何将建立在本地的仓库上传到Gitee中

在本地项目目录创建本地仓库

 git init  

输入命令后项目目录会有一个隐藏的.git文件夹

上传所有代码到本地仓库

git add.   (注意add后面有个点,与add之间有一空格)

这样就把代码上传到本地仓库了

 git commit -m "initial commit"

Git如何将建立在本地的仓库上传到Gitee中it

在gitee上新建项目,复制https://gitee.com/xxx/xx.git地址

关联本地仓库并上传代码

git remote add origin https://github.com/Yanyf765/hr_sys.git(上步骤复制的地址)

git push origin master

报错:

Git如何将建立在本地的仓库上传到Gitee中

执行命令:

git pull origin master --allow-unrelated-histories

Git如何将建立在本地的仓库上传到Gitee中

git 在pull或者合并分支的时候有时会遇到这个界面。可以不管(直接下面3,4步),如果要输入解释的话就需要:

1.按键盘字母 i 进入insert模式

2.修改最上面那行黄色合并信息,可以不修改

3.按键盘左上角"Esc"

4.输入":wq",注意是冒号+wq,按回车键即可

之后就可以成功的pull,push了

Git如何将建立在本地的仓库上传到Gitee中

提交到远程报错,如下:

Git如何将建立在本地的仓库上传到Gitee中

src refspec master does not match any

原因:

本地仓库为空

解决方法:

使用如下命令 添加文件;

$ git add add.php addok.php conn.php del.php edit.php editok.php ftpsql.sql index.php
 
$ git commit -m "init files"

之后在push过程中出现如下错误:

$ git push -u origin master
Warning: Permanently added the RSA host key for IP address 'xx.xx.xxx.xxx' to the list of known hosts.
To git@github.com:hahaha/ftpmanage.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:hahahah/ftpmanage.git'
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 integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

提示使用 git pull 之后在 push

使用如下命令解决:

$ git pull --rebase origin master
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From github.com:hahah/ftpmanage
 * branch  master -> FETCH_HEAD
 * [new branch] master -> origin/master
First, rewinding head to replay your work on top of it...
Applying: init files

继续push,成功。

Git如何将建立在本地的仓库上传到Gitee中

看完上述内容,你们对Git如何将建立在本地的仓库上传到Gitee中有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注亿速云行业资讯频道,感谢大家的支持。

推荐阅读:
  1. eclipse创建git本地仓库,并将本地仓库更新到远端git服务器
  2. 将gitee远程仓库抓取(克隆)到本地仓库

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

git 本地仓库 gitee

上一篇:如何利用java实现获取一个文件的编码

下一篇:windows系统部署JAVA环境时如何安装iDea

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》