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

所属分类: 网络编程 / 相关技巧 阅读数: 270
收藏 0 赞 0 分享

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

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

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

git config --global user.name "xxxx" 

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

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

 git init  

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

上传所有代码到本地仓库

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

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

 git commit -m "initial commit"

it

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

关联本地仓库并上传代码

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

git push origin master

报错:

执行命令:

git pull origin master --allow-unrelated-histories

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

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

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

3.按键盘左上角"Esc"

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

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

提交到远程报错,如下:

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,成功。

更多精彩内容其他人还在看

程序员编程从初级到中级的10个秘诀

在一封与TechRepublic会员交流的邮件当中,他提到了面向程序员的博客、文章及杂志分成两类:面向初学者类(“hello world”这种类型的教程)以及面向专家类(MSDN杂志)。
收藏 0 赞 0 分享

关于换行和回车的图文小结

不知道大家用这么多年的电脑,写了这么多的程序,对换行和回车有没有一个认识
收藏 0 赞 0 分享

回车和换行有什么区别?我们平时按下的Enter键是回车还是换行

如果用过机械打字机,就知道回车和换行的区别了。换行就是把滚筒卷一格,不改变水平位置。回车就是把水平位置复位,不卷动滚筒
收藏 0 赞 0 分享

网络编程之get与post的区别与联系

这里来说说get与post的区别与联系,对这方面不懂的鹏哟可以参考下。
收藏 0 赞 0 分享

Web开发人员常用速查手册 英文集合推荐

不管你是多么优秀的程序员,你都不可能记住一切。在你编写程序的过程中碰到问题需要查阅手册的时候,若有现成的手册可参考则可以为你节省很多时间。
收藏 0 赞 0 分享

vs快捷键 用好Ctrl+Enter与Ctrl+Shift+Enter组合键让你的编辑代码速度快了很多

使用Ctrl+Enter组合键在上方插入一行,使用Ctrl+Shift+Enter组合键在下方插入一行
收藏 0 赞 0 分享

对Web开发人员有用的8个网站小结

本文是由比利时的Web开发人员Jean-Baptiste Jung分享的,Jung还在《Web开发/设计人员应当知道的15个网站》这篇文章中推荐了15个相关网站
收藏 0 赞 0 分享

Web开发/设计人员应当知道的15个网站

建个好网站绝非易事,工欲善其事必先利其器。本文编译了15个极其有用的网站,任何一位网站开发者或设计人员都应该收藏起来
收藏 0 赞 0 分享

Application,Session,Cookies对象应用介绍

Application,Session,Cookies对象比较,对于客户端保存登录信息的朋友可以参考下。
收藏 0 赞 0 分享

设计高可用和高负载的网站系统的几个注意事项

随着网站的运营,用户访问量和数据存储量会随着时间发生几何级变化,很快整个系统不堪重负,频繁出现问题。
收藏 0 赞 0 分享
查看更多