Git简单使用

Git基本命令

git init  初始化本地仓库
            git add ./<filename> (.)所有文件都提交到缓存区
            git commit -m "描述信息"
            git status  状态  红色:工作区 绿色:缓存区 白色:本地仓库
            git log   git log --oneline查看提交的历史记录
            git reflog 所有的操作记录
            git checkout <filename> 丢弃工作区的内容
            git reset <filename>  暂存区回退工作区
            git reset <commit_id>  版本回退 不动文件内容
            git reset --hard <commit_id> 版本文件内容回退
                合并出现冲突
            --    先查看状态
            -- 手动解决冲突
            -- 提交到仓库

分支管理

git branch <branch_name> 创建分支
            git checkout <branch_name> 切换分支
            git branch -d <branch_name 删除分支
            git merge <branch_name> 合并到当前分支
            git branch 查看所有分支
            合并的时候会冲突
                手动解决冲突
                提交到仓库

标签管理

            git tag <name> <commit_id> 创建标签
            git tag -d <tag_name> 删除标签
            git tag  查看所有标签
            git tag <tag_name> <commit_id>  给指定的记录加标签
            git push tag <name>

远程仓库

            https
                git remote add s1 https..地址
            ssh
                在用户的目录下生成公钥私钥
                    命令 ssh-keygen -t rsa -C "email"
                    在 .ssh目录下
                把公钥放入GitHub上
                跟远程仓库做连接      git remote add 别名 ssh地址
                git remote 查看所有的远程仓库
                推送代码到远程仓库
            git push -u s1 master
        克隆仓库
            git clone 仓库地址
        从远程仓库拉去代码
            git pull origin master
            如果远程仓库有变化
                会存在push失败的情况
                先拉去代码再push    

协同开发

1.线上的分支
线上的保险分支 备份
开发分支 master,每个人分支
在自己的分支下开发


2.先提交到测试分支
测试通过
提交到自己的远程仓库的分支


3.线上出现bug
回滚到之前稳定版本
建立bug分支
在bug分支解决bug

转载于:https://www.cnblogs.com/yidashi110/p/10156167.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值