windows下使用git命令行将本地项目提交到git服务器

来源:互联网 发布:世界上第一个女程序员 编辑:程序博客网 时间:2024/05/20 09:08
在使用命令行之前,需要你在git服务器中已经存在一个创库地址,比如:git@gitlab.com:xiangrong/base-test.git,然后你自己下面开始正题:1.使用cmd进入dos界面。创建本地git的公钥和私钥。使用下面的命令会创建~/.ssh/id_rsa和~/.ssh/id_rsa.pub密钥对。ssh-keygen -t rsa -C "$your_email"2.将生成的公钥信息保存到服务器中。在面板上依次点击Profile Settings –> SSH Keys –> Add SSH Keys。然后把上一步中的id_rsa.pub中的内容拷贝出来粘贴到输入框中,保存。3.初始化上传代码进入自己项目的根目录: cd $project_root初始化自己的创库:    git init 添加文件到本地创库:  git add .添加本次提交的注释:  git commit -m "init commit"将本地创库和git创库链接:git remote add origin git@gitlab.com:xiangrong/base-test.git将本地代码上传到服务器:git push origin master可能遇见的出问题:1.提交注释的时候提示一下信息。$ git commit * -m "fixed issue #123"error: pathspec 'composer' did not match any file(s) known to git.error: pathspec 'composer.lock' did not match any file(s) known to git.error: pathspec 'vendor' did not match any file(s) known to git.解决方法:git rm -r --cached .2.在提交信息到git服务器的时候,提示:error:src refspec master does not match any原因是提交的信息是空,解决办法:查看你自己的当前分支是不是有值
0 0
原创粉丝点击