首先测试git是否安装成功 在cmd中输入命令
git --version
如果成功会出现版本信息
注册申请码云账户码云注册网址,新建远程服务项目仓储,获得ssh公匙复制留作备用。
首先初始化git
git init
查看提交到git上的文件,并查看是否提交成功,成功后git status为绿色。
git add .
git status
git commit -am "first commit project" //提交到git服务 -am 为全部提交 ,first commit project为第一次提交的备注
文件commit到本地git之后需要push到码云服务上执行
git remote add origin git@git.oschina.net:XXXXXXXXX//:加申请的公匙 连接到码云服务器端
连接后把把本地服务推动到远程
git push -u origin master
出现错误提示,提示需要git pull 更新服务上的代码
Enter passphrase for key '/c/Users/Thinkpad/.ssh/id_rsa':
To gitee.com:FangHuaShiJie/leaning_newmmall.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@gitee.com:XXXXXXX/XXXXXXXXX.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
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
git pull
git push -u -f origin master //执行强制刷新
会提示更新成功,此时可以再码云查看是否上传成功