Git建立本地仓库并上传到Gitee的详细步骤

 

这篇文章主要介绍了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的详细步骤

在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的文章就介绍到这了,更多相关Git建立本地仓库内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

文章转自脚本之家,原文链接:https://www.jb51.net/article/193672.htm

免责申明:
1. 本站所有下载资源均不包含技术支持和安装服务!需要讨论请进群!
2. 分享目的仅供大家学习和交流,请不要用于商业用途!
3. 如果你也有好源码或者教程,可以到审核区发布,分享有KR奖励和额外收入!
4. 如有链接无法下载、失效或广告,请联系管理员处理!
5. 本站无法保证资源或破解时效性,如某些授权码过期等问题,恕不在修复范围内。
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!故不接受任何形式的退款,如确认资源确有问题的,会补给相应KR以供再次购买。
7. 53Kr源码暂未发现后门代码,但无法保证100%安全,推荐检测方法:上传到 https://www.virustotal.com/在线查看是否有恶意代码以及其他有后门嫌疑的代码。
8. 在本站下载的源码我还是不建议正式使用,有特别喜欢的可以去程序官方购买。
53kr资源站仅提供学习的平台,所有资料均来自于网络,版权归原创者所有!本站不提供任何保证,并不承担任何法律责任,如果对您的版权或者利益造成损害,请提供相应的资质证明,我们将于3个工作日内予以删除。
53kr资源分享 » Git建立本地仓库并上传到Gitee的详细步骤

发表回复