git 協做開發 - 短信接口 - redis 基礎

早上第二個視頻,有從頭至尾走一遍的

兩分左右有整個流程mysql

git@gitee.com:doctor_owen/luffyapi.gitgit

被添加到項目的開發者中redis

複習

"""
一、版本管理器:管理在編寫代碼時,各類代碼版本的工具 - 通常在一個需求或是一項功能代碼結束後,就稱之爲一個代碼版本
二、svn和git比較:git服務端與客戶端整合,每個倉庫均可以做爲客戶端也能夠做爲服務端(集羣部署、不怕服務器宕機)、git能夠多分支操做,分支管理很強大
三、git的工做流程:工做區 <=> 暫存區 <=> 版本庫 <=> 遠程倉庫 <=> 版本庫
    增刪改查            |       git checkout .
    git add .           |      git reset HEAD . (git reset)
    git commit -m '信息'  |      git reset --hard 版本號  (git reflog | gitlog)
    
四、基礎命令
    git init
    git status

五、remote
    git remote | git remote -v
    git remote add 源名 地址
    git remote remove 源名

六、branch
    git branch
    git branch 新分支 | git checkout -b 新分支
    git checkout 分支
    git branch -d 分支
    
七、gitee遠程倉庫
    本地倉庫提交代碼到本地版本庫
    建立遠程倉庫,將本地主機添加至開發者
    本地倉庫配置遠程倉庫remote源
    提交代碼到遠程倉庫
    
八、提早配置 - 在第一次提交版本庫以前完成
    本地倉庫的全局或局部用戶信息
    本地主機要生成公鑰私鑰
    配置倉庫的過濾條件
"""

同步項目

而後 git clone git@gitee.com:doctor_owen/luffyapi.git 便可把項目同步到本地sql

# 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

版本衝突

常規操做,先拉後提交數據庫

我有的 服務器沒有,服務器有的我沒有(這時我要提交)django

不一致的時候,必須先 pull 後 push(在 pull 以前,要先 加到工做區 本地版本庫(git add . git commit -m "備註信息"))api

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操做

"""
一、開發前,拉一次遠程倉庫
二、工做區進行開發
三、將開發結果提交到本地版本庫 - git status查看時沒有待處理的事件
四、拉取遠程倉庫(每一次要提交遠程倉庫前必須先拉)
五、若是出現衝突,線下溝通(協商從新開發衝突文件),要從新走三、4步
六、沒有衝突,提交到遠程倉庫
"""

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
相關文章
相關標籤/搜索