上传项目到本地gitLab

将本地项目上传到GitLab:

git init
  • 1
git add .
  • 1
git remote add origin git@gitlab.xxxx.com:loangroup/xxxx.git
  • 1

报错:fatal: remote origin already exists. 删除远程已经存在的origin:

git remote rm origin 
  • 1

然后继续:

git remote add origin git@gitlab.xxxx.com:loangroup/xxxx.git
  • 1

将代码push:

git push
  • 1

又报错,不过有提示信息:
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream origin master
  • 1
  • 2


按照提示信息输入命令:

git branch --set-upstream-to master origin/master
  • 1

报错:fatal: branch ‘origin/master’ does not exist

先提交本地代码到本地仓库:

git commit -m "commit"  
  • 1

提交代码到远程仓库:

 git push --set-upstream origin master
  • 1

要求输入密码:[email protected]’s password:

终于到最后了,编辑当前项目.git/config 文件,将

url=git@gitlab.xxx.com/loangroup/ml-sso.git 
  • 1

改成:

 url = http://gitlab.xxx.com:8081/loangroup/xxx.git
  • 1

最后再执行下下面的命令就可以了:

 git push --set-upstream origin master

猜你喜欢

转载自blog.csdn.net/www5256246/article/details/80897190