idea中使用Git将本地项目提交到gitee仓库中
在idea中使用Git管理项目代码时一般都是克隆远程仓库到本地,进行项目代码的开发,
但有时在本地创建的项目需要提交到对应的gitee仓库中,步骤如下:
1.新建项目:
以及gitee上的远程仓库:
2.创建本地仓库:
3.将项目添加到暂存区:
4.配置远程仓库:
其中url地址为想上传到gitee的远程仓库的地址
5.将项目进行commit以及push:
5.在push到远程仓库的时候报错:
20:43:56.735: [gitdemo3] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false push --progress --porcelain origin refs/heads/master:master --set-upstream
To https://gitee.com/Dames/gitdemo.git
error: failed to push some refs to 'https://gitee.com/Dames/gitdemo.git'
! refs/heads/master:refs/heads/master [rejected] (fetch first)
hint: Updates were rejected because the remote contains work that you do
Done
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.
根本原因是远程仓库和本地仓库内容不同,将远程仓库中不同的内容pull到本地,就好了:
在当前项目的文件夹中打开Git Batch:
输入:git pull --rebase origin master
可以看到项目中把仓库的文件pull下来了:
再次进行push,成功上传: