这篇文章主要(yao)介绍了Git建立本地仓库并上(shang)传到Gitee,立本本文给大家介绍的非常详细,对大家的地仓到G的详学(xue)习或工作具(ju)有一定(ding)的参(can)考借鉴价值,需要的库并朋友可以参考下
电脑安装git客户端、注册github账号并登陆

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

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

git config --global user.name "xxxx"
git config --global user.email xxxxx@qq.com
在本地项目目录创建本地仓库
git init
输入命令后项目目录会有一个隐藏的上传.git文件夹
上传所有代码到本地仓库
git add. (注意add后面(mian)有个点,与add之间有一空格)
这样就把代码上传到本地仓库了
git commit -m "initial commit"
在gitee上新建项目,细步复制https://gitee.com/xxx/xx.git地址
关联本地仓库并上传代码
git push origin master
报(bao)错:
执行命令:
git pull origin master --allow-unrelated-histories
git 在pull或者合并分支的时(shi)候有(you)时会遇到这个界面。可以不管(直接下面(mian)3,地仓到G的详4步),如(ru)果要输入解释的库并话就需要:
1.按键盘字母 i 进入insert模式
2.修改最上(shang)面那行黄色合并信息,可以不修(xiu)改
3.按键盘左上角"Esc"
4.输入":wq",注意是冒号+wq,按回车键即可
之后就可以(yi)成功的pull,push了
提(ti)交到远程报错,上传如下:
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过(guo)程(cheng)中出(chu)现如下错误:
$ 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
提示(shi)使用 git pull 之(zhi)后在 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,成功。立(li)本
总结
到此这篇关于Git建立(li)本地仓库并上传(chuan)到Gitee的地仓到G的详文章就介绍到这了,更多相关Git建(jian)立本地仓库内容请搜索脚本之家以前(qian)的文章或继续浏览下面的相关文(wen)章希望大家(jia)以后多多支(zhi)持脚本之家(jia)!
文章转自脚本之家,原文链接:https://www.jb51.net/article/193672.htm
库并