管理
- 在项目根目录创建几个文件:
-
.gitignore
node_modules .idea .vscode .git
-
README.md
-
LICENSE //开源协议
- 在项目根目录
git init
- git status
- git add .
- git commit -m “修改”
- https://gitee.com
- 查看自己有无公钥
- c:\用户[用户名].ssh (是否有此.ssh文件)
- 进入 .ssh , id_rsa.pub 为自己的公钥
- 将公钥放入码云中,确定
- 如果没有公钥,则先生成公钥:
- 在 git bash 里输入
ssh-keygen -t rsa -C "xxxx@xxxx.com"
//邮箱改为自己的邮箱 cat ~/.ssh/id_rsa.pub
查看公钥
- 在 git bash 里输入
- 创建仓库:新建项目-》创建
- Git 全局设置:
git config --global user.name "xxx"
git config --global user.email "xxx@xxx.com"
- 已有仓库
cd existing_git_repo
git remote add origin https://gitee.com/xxxxxx.git
git push -u origin master
git免密登录
一. url 中进行体现:
原来的地址: https://github.com/wucs/test.git
修改的地址: https://用户名:密码@github.com/wucs/test.git
git remote add origin https://用户名:密码@github.com/wucs/test.git
git push origin master
如果已经有地址,可以修改配置文件中的地址,将用户名、密码添加到url中
二、 通过 ssh实现
- 生成公钥和私钥
-
ssh-keygen
-
默认放在 ~/.ssh
- 拷贝公钥内容,设置到github中
- 在 git 本地中配置 ssh 地址
- git remote add origin git@githun.com:wucs/test.git
三、 git 自动管理凭证
配置文件存放三个位置
- 项目配置文件: 项目/.git/config
git config --local user.name 'wucs'
git config --local user.email 'wuchengshi11@163.com'
- 全局配置文件: ~/.gitconfig
git config --global user.name 'wucs'
git config --global user.email 'wuchengshi11@163.com'
- 系统配置文件:/etc/.gitconfig
git config --system user.name 'wucs'
git config --system user.email 'wuchengshi11@163.com'
注意:需要有 root 权限