04 git -- 管理、配置

管理

  1. 在项目根目录创建几个文件:
  • .gitignore

    node_modules
    .idea
    .vscode
    .git
    
  • README.md

  • LICENSE //开源协议

  1. 在项目根目录 git init
  • git status
  • git add .
  • git commit -m “修改”
  1. https://gitee.com
  2. 查看自己有无公钥
    • c:\用户[用户名].ssh (是否有此.ssh文件)
    • 进入 .ssh , id_rsa.pub 为自己的公钥
    • 将公钥放入码云中,确定
  3. 如果没有公钥,则先生成公钥:
    • 在 git bash 里输入 ssh-keygen -t rsa -C "xxxx@xxxx.com" //邮箱改为自己的邮箱
    • cat ~/.ssh/id_rsa.pub 查看公钥
  4. 创建仓库:新建项目-》创建
  5. Git 全局设置:
git config --global user.name "xxx"
git config --global user.email "xxx@xxx.com"
  1. 已有仓库
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实现
  1. 生成公钥和私钥
  • ssh-keygen

  • 默认放在 ~/.ssh

  1. 拷贝公钥内容,设置到github中
  2. 在 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 权限
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

有码无尘

知识无价,有收获就好!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值