1、gitee代码上传
1.在项目内空白处右键Git Bash Here,配置用户名和邮箱
-
git config --global "xxx"
-
git config --global "xxx"
-
#检查用户名和邮箱指令
-
git config
-
git config
2.命令行输入下列命令,初始化本地仓库
git init
3.添加项目目录下所有文件至本地仓库
git add .
4.使用如下命令加入注释提交(说明信息为必填项,便于后期理解,此步骤必不可少!)
git commit -m '本次提交的说明'
5.将本地仓库与远程仓库相连接
git remote add origin xxx
6.将本地仓库中的文件推送至指定的远程仓库中
git push -u origin master
如果出错error: failed to push some refs to ‘xxx“
-
出现错误的主要原因是gitee(github)中的README.md文件不在本地代码目录中
-
此时我们要执行git pull --rebase origin master命令README.md拉到本地,
-
任何然后执行git push origin master
2、gitee分支代码上传
1.在项目内空白处右键Git Bash Here,配置用户名和邮箱
-
git config --global "xxx"
-
git config --global "xxx"
-
#检查用户名和邮箱指令
-
git config
-
git config
2.命令行输入下列命令,初始化本地仓库
git init
3.添加项目目录下所有文件至本地仓库
git add .
4.使用如下命令加入注释提交(说明信息为必填项,便于后期理解,此步骤必不可少!)
git commit -m '本次提交的说明'
5.查看所有分支 (看看是否连接上远程的git)
git branch -a
6.创建分支(xxx为你的分支起名字)
git branch xxx
7.切换分支(切换到你创建的分支,xxx为你要切换分支的名字)
git checkout xxx
8.提交代码到指定的分支 (xxx为要提交代码的分支名称)
git push origin xxx
输入git push -u origin xxx命令后出现如下错误提示:
-
fatal: 'origin' does not appear to be a git repository
-
fatal: Could not read from remote repository.
-
-
Please make sure you have the correct access rights
-
and the repository exists.
出现原因: 不存在origin远程仓库
解决方法: 重新关联远程仓库(xxx是远程库地址)
git remote add origin xxx
-
#出现问题:
-
fatal: 远程 origin 已经存在
-
解决:
-
#删除远程配置
-
git remote rm origin
-
#重新添加
-
git remote add origin xxx
-
#再上传一下代码(xxx是分支名称)
-
git push origin xxx
-
-