Git的使用

mkdir hello 创建文件夹
ls -a 查看所有
git init 初始化
**基本操作
ls -a
cd .git/
ls master一般是git默认的主分支
cd …
rm -r .git
touch a text
git status
git add a.txt
git status
git rm --cached 撤销
git commit -m “第一次提交”
git status 检测工作目录是否干净
vim a.text 修改
git add a.text
git commit -m “第二次提交”
touch b.text
touch c.text
git b
git c
git commit “第三次提交”
git diff filename 查看具体的改动

**版本回溯
vim a.text进行修改
cat a.text查看修改之后状况
git add .
git commit -m “第四次提交”
git log 查看之前的所有提交记录
git rest --hard 加上版本代号
git log --pretty=oneline简洁的记录
git reset --hard HEAD^ 回到上一个版本
git reflog 每一次版本提交和修改

**撤销
git checkout – a.text 撤销操作,返回修改
git reser HEAD a.text 也是撤销

**删除文件
git rm filename删除文件

**远程仓库
RSA加密:非对称加密方式
ssh-keygen -t rsa -C “610974136@qq.com”

打开github网站–设置–SSH and GPG–New SSH–cd /路径//
–pwd–ls–cat id_rsa.pub输出密公钥–ssh-add id_rsa添加私钥
–ssh-agent bash这个放在上面一步之前解决权限问题

**远程本地产生关联
cd hello2 ls
git remote add origin https网址
git remote 查看连接哪个仓库
git remote remove origin 删除连接
git push -u origin master 第一次推送文件 origin代表远程仓库的地址
##后面的推送不需要-u

**克隆
cd到桌面 git clone https地址
git add. git commit -u “”
git push origin master
git pull origin master完整的拉取下来
pull不需要密码 push需要密码
不同用户进行推送的前提是都有最新版本的远程的本地仓库

mkdir hello4 cd hello4
git init ls git remote origin git地址
git pull origin master 钥匙变绿
touch file git add . git commit -m “”
git push origin master这样 push 不需要密码

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值