zoukankan      html  css  js  c++  java
  • git 协作开发

    早上第二个视频,有从头到尾走一遍的

    两分左右有整个流程

    git@gitee.com:doctor_owen/luffyapi.git

    被添加到项目的开发者中

    复习

    """
    1、版本管理器:管理在编写代码时,各种代码版本的工具 - 一般在一个需求或是一项功能代码结束后,就称之为一个代码版本
    2、svn和git比较:git服务端与客户端整合,每一个仓库都可以作为客户端也可以作为服务端(集群部署、不怕服务器宕机)、git可以多分支操作,分支管理很强大
    3、git的工作流程:工作区 <=> 暂存区 <=> 版本库 <=> 远程仓库 <=> 版本库
    	增删改查		 	| 		git checkout .
    	git add .			|	   git reset HEAD . (git reset)
    	git commit -m '信息' 	|	   git reset --hard 版本号  (git reflog | gitlog)
    	
    4、基础命令
    	git init
    	git status
    
    5、remote
    	git remote | git remote -v
    	git remote add 源名 地址
    	git remote remove 源名
    
    6、branch
    	git branch
    	git branch 新分支 | git checkout -b 新分支
    	git checkout 分支
    	git branch -d 分支
    	
    7、gitee远程仓库
    	本地仓库提交代码到本地版本库
    	创建远程仓库,将本地主机添加至开发者
    	本地仓库配置远程仓库remote源
    	提交代码到远程仓库
    	
    8、提前配置 - 在第一次提交版本库之前完成
    	本地仓库的全局或局部用户信息
    	本地主机要生成公钥私钥
    	配置仓库的过滤条件
    """
    

    同步项目

    然后 git clone git@gitee.com:doctor_owen/luffyapi.git 即可把项目同步到本地

    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (master)
    $ git config user.name "Suwanbin"
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (master)
    $ git config user.email "1335951413@qq.com"
    
    # 新建一个文件 test.txt
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (master)
    $ git status
    On branch master
    Your branch is up to date with 'origin/master'.
    
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
    
            test.txt
    
    nothing added to commit but untracked files present (use "git add" to track)
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (master)
    $ git add .
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (master)
    $ git commit -m "测试保护分支"
    [master a7604ea] 测试保护分支
     1 file changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 test.txt
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (master)
    $ git remote
    origin
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (master)
    $ git push origin master
    Enumerating objects: 3, done.
    Counting objects: 100% (3/3), done.
    Delta compression using up to 4 threads
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (2/2), 279 bytes | 279.00 KiB/s, done.
    Total 2 (delta 1), reused 0 (delta 0)
    remote: Access denied: You do not have permission to push to the protected branch 'master' via SSH
    remote: error: hook declined to update refs/heads/master
    To gitee.com:doctor_owen/luffyapi.git
     ! [remote rejected] master -> master (hook declined)
    error: failed to push some refs to 'git@gitee.com:doctor_owen/luffyapi.git'
    
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (master)
    $ git checkout -b dev
    Switched to a new branch 'dev'
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git add .
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git commit -m "test.py 测试分支"
    [dev 1aa6aa8] test.py 测试分支
     1 file changed, 1 insertion(+)
     create mode 100644 test.py
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git push origin dev
    Enumerating objects: 6, done.
    Counting objects: 100% (6/6), done.
    Delta compression using up to 4 threads
    Compressing objects: 100% (4/4), done.
    Writing objects: 100% (5/5), 516 bytes | 516.00 KiB/s, done.
    Total 5 (delta 2), reused 0 (delta 0)
    remote: Powered By Gitee.com
    To gitee.com:doctor_owen/luffyapi.git
     * [new branch]      dev -> dev
    
    
    
    

    版本冲突

    常规操作,先拉后提交

    我有的 服务器没有,服务器有的我没有(这时我要提交)

    不一致的时候,必须先 pull 后 push(在 pull 之前,要先 加到工作区 本地版本库(git add . git commit -m "备注信息"))

    git pull
    

    暂时还没拉下来

    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git status
    On branch dev
    nothing to commit, working tree clean
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git reflog
    1aa6aa8 (HEAD -> dev, origin/dev) HEAD@{0}: commit: test.py 测试分支
    a7604ea (master) HEAD@{1}: checkout: moving from master to dev
    a7604ea (master) HEAD@{2}: commit: 测试保护分支
    5d2442c (origin/master, origin/HEAD) HEAD@{3}: clone: from git@gitee.com:doctor_owen/luffyapi.git
    
                
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git pull
    remote: Enumerating objects: 24, done.
    remote: Counting objects: 100% (23/23), done.
    remote: Compressing objects: 100% (18/18), done.
    remote: Total 20 (delta 10), reused 0 (delta 0)
    Unpacking objects: 100% (20/20), done.
    From gitee.com:doctor_owen/luffyapi
       1aa6aa8..b7a5183  dev        -> origin/dev
    There is no tracking information for the current branch.
    Please specify which branch you want to merge with.
    See git-pull(1) for details.
    
        git pull <remote> <branch>
    
    If you wish to set tracking information for this branch you can do so with:
    
        git branch --set-upstream-to=origin/<branch> dev
    
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git pull origin dev
    From gitee.com:doctor_owen/luffyapi
     * branch            dev        -> FETCH_HEAD
    Updating 1aa6aa8..b7a5183
    Fast-forward
     luffyapi/a.py        | 7 +++++++
     luffyapi/bob_test.py | 3 +++
     2 files changed, 10 insertions(+)
     create mode 100644 luffyapi/a.py
     create mode 100644 luffyapi/bob_test.py
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git reflog
    b7a5183 (HEAD -> dev, origin/dev) HEAD@{0}: pull origin dev: Fast-forward
    1aa6aa8 HEAD@{1}: commit: test.py 测试分支
    a7604ea (master) HEAD@{2}: checkout: moving from master to dev
    a7604ea (master) HEAD@{3}: commit: 测试保护分支
    5d2442c (origin/master, origin/HEAD) HEAD@{4}: clone: from git@gitee.com:doctor_owen/luffyapi.git
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git add.
    git: 'add.' is not a git command. See 'git --help'.
    
    The most similar command is
            add
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git add .
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git commit -m "修改test.py,加了个循环"
    [dev dd5916d] 修改test.pyy,加了个循环
     1 file changed, 4 insertions(+), 1 deletion(-)
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git status
    On branch dev
    nothing to commit, working tree clean
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git pull
    There is no tracking information for the current branch.
    Please specify which branch you want to merge with.
    See git-pull(1) for details.
    
        git pull <remote> <branch>
    
    If you wish to set tracking information for this branch you can do so with:
    
        git branch --set-upstream-to=origin/<branch> dev
    
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git pull origin dev
    From gitee.com:doctor_owen/luffyapi
     * branch            dev        -> FETCH_HEAD
    Already up to date.
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git push origin dev
    Enumerating objects: 5, done.
    Counting objects: 100% (5/5), done.
    Delta compression using up to 4 threads
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 333 bytes | 333.00 KiB/s, done.
    Total 3 (delta 1), reused 0 (delta 0)
    remote: Powered By Gitee.com
    To gitee.com:doctor_owen/luffyapi.git
       b7a5183..dd5916d  dev -> dev
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git pull origin dev
    remote: Enumerating objects: 10, done.
    remote: Counting objects: 100% (10/10), done.
    remote: Compressing objects: 100% (5/5), done.
    remote: Total 6 (delta 2), reused 0 (delta 0)
    Unpacking objects: 100% (6/6), done.
    From gitee.com:doctor_owen/luffyapi
     * branch            dev        -> FETCH_HEAD
       dd5916d..835d53e  dev        -> origin/dev
    Updating dd5916d..835d53e
    Fast-forward
     test.py | 9 ++++++++-
     1 file changed, 8 insertions(+), 1 deletion(-)
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git pull origin dev
    From gitee.com:doctor_owen/luffyapi
     * branch            dev        -> FETCH_HEAD
    Already up to date.
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git add .
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git commit -m "test: if 2"
    [dev 49c342c] test: if 2
     1 file changed, 1 insertion(+)
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git status
    On branch dev
    nothing to commit, working tree clean
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git pull origin dev
    From gitee.com:doctor_owen/luffyapi
     * branch            dev        -> FETCH_HEAD
    Already up to date.
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git push origin dev
    Enumerating objects: 5, done.
    Counting objects: 100% (5/5), done.
    Delta compression using up to 4 threads
    Compressing objects: 100% (3/3), done.
    Writing objects: 100% (3/3), 312 bytes | 312.00 KiB/s, done.
    Total 3 (delta 1), reused 0 (delta 0)
    remote: Powered By Gitee.com
    To gitee.com:doctor_owen/luffyapi.git
       835d53e..49c342c  dev -> dev
    
    
    # Administrator@PC-20190116XBHT MINGW64 ~/Desktop/luffyapi (dev)
    $ git pull origin dev
    remote: Enumerating objects: 27, done.
    remote: Counting objects: 100% (27/27), done.
    remote: Compressing objects: 100% (18/18), done.
    remote: Total 19 (delta 8), reused 0 (delta 0)
    Unpacking objects: 100% (19/19), done.
    From gitee.com:doctor_owen/luffyapi
     * branch            dev        -> FETCH_HEAD
       49c342c..0dc7c18  dev        -> origin/dev
    Updating 49c342c..0dc7c18
    Fast-forward
     test.py | 9 +++++++--
     1 file changed, 7 insertions(+), 2 deletions(-)
    
    

    合并分支

    一个项目可以设置 审核人员,普通人员

    自己合并(有哪些命令再看下?)

    在 dev 下执行 git merge bob

    在 z 分支执行命令,合并 x 分支

    git pull origin devgit push origin dev

    下午日考:

    1.git提交1.txt到暂存区

    git add 1.txt

    2.git完成第一次项目初始化到版本库命令

    git add .
    git 
    

    3.合并dev分支到master分支命令

    项目开发 git操作

    """
    1、开发前,拉一次远程仓库
    2、工作区进行开发
    3、将开发结果提交到本地版本库 - git status查看时没有待处理的事件
    4、拉取远程仓库(每一次要提交远程仓库前必须先拉)
    5、如果出现冲突,线下沟通(协商重新开发冲突文件),要重新走3、4步
    6、没有冲突,提交到远程仓库
    """
    

    Redis 数据库

    1. 为什么要用 redis 数据库,而不用常见的数据库呢?
    • redis 是内存数据库,相比 mysql 等硬盘数据库效率高
    1. 为什么在内存中配置数据库使用,而不直接使用内存?
    • redis 存储的数据是可以管理的
    1. memcache 也是内存数据库,且 django 默认采用的就是 memcache 数据库,为什么要使用 redis 而不使用 memcache
    • redis 更强大,支持更多的数据类型
    • redis 自带缓存机制,出现数据库系统崩溃,数据也是可以有找回的功能
    • redis 可以主动完成数据持久化(自带数据持久化功能)
    • redis 的数据过期时间机制也可以自身完成

    下载安装

    官网下载安装包,安装(默认安装就好了)

    记得勾选添加到环境变量中

    redis 数据类型

    """
    支持的数据类型:String、Hash、List、Set、Sorted Set
    
    String:存储其他类型不能存的所有数据
    Hash:存储 key-value 形式数据,类似于字典
    List:存储 一系列有序value 形式数据,列表(数组)
    Set:存储 一系列无序value 形式数据,集合
    Sorted Set:存储 有排列标号value 形式数据,排行
    """
    

    有序集合一般用来做排行版,内存中要实时更新,查询效率要求比较高的数据(每次查询只是查前多少条就行了)

    字符串还是用的最多的,因为后台的数据一般都要序列化返回给前台,只要能够序列化,就一定能变成字符串,然后可以反序列化回来

    # 字符串类型最常用的操作
    set key value
    get key
    
    mset key1 value1 key2 value2 ...
    mget key1 key2 ...
    
    setex key expir_time value
    get key
    
  • 相关阅读:
    失效的Eclipse API(一)
    contiki系统分析四:内存分配
    Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
    Error about updating UI in background thread
    ubuntu 安装ssh server
    [置顶] 树链剖分小节
    [置顶] LCA的树链剖分实现
    飞天开放平台编程指南——阿里云计算的实践
    一道C#面试题
    jQuery参考实例 1.8 将前一次选择的元素集合并到当前选择的元素集中
  • 原文地址:https://www.cnblogs.com/suwanbin-thought/p/11759907.html
Copyright © 2011-2022 走看看