创建本地Git并提交到码云

概述

安装Git,使用Git Bash创建本地Git全局用户名,提交远程代码时将以此用户名显示
git config --global --replace-all user.email "itoracle@aliyun.com"
git config --global --replace-all user.name "itoracle"

在码云上创建一个git:https://gitee.com/itdb/all.git

进入D盘
cd /d
下载远程git到本地
git clone https://gitee.com/itdb/all.git
#在本地添加一个远程git配置all,以后all就代表了远程的 https://gitee.com/itdb/all.git; 本地可以配置多个远程git,那么就需要为不同的远程git起个名字。
git remote add all https://gitee.com/itdb/all.git

配置SSH
cd /c/Users/thinkpad
ssh-keygen -t rsa -C "itoracle@aliyun.com"
cd .ssh
cat id_rsa.pub
$ cat id_rsa.pub
ssh-rsa AAAAB3……n.com
将本地公钥复制到以下地方
设置-->安全设置-->SSH公钥

复制文件到git目录并上传到远程git,首次提交需要加-u
cp -r /e/all/fxzonghe_cmd /d/all

cd /d/all
git add .
git status
git commit -m "ppcore first commit"
将本地git推送到远程all的master分支
git push -u all master


第二次提交,没有使用-u参数
cd /d/all
git add .
git status
git commit -m "all second commit"
git push all master

git常用操作

从远程拉取文件到本地

git clone https://…….git

 拉取
拉取远程服务器notebook的master分支
git pull notebook master

提交
git add  .
git commit -m "2019.11.20"
git push  notebook master

遇到错误

remote: GitLab: You are not allowed to push code to protected branches on this project.

这是提交者的权限不够,开发者角色不行,需要提升为管理员角色

 

posted @ 2019-01-22 11:04  方诚  阅读(135)  评论(0编辑  收藏  举报