在進行開發的時候,程序須要常常性的修改,那麼修改的時候就存在備份問題,當代碼量較大修改頻繁時,備份的及時性和備份的困難度就增長了。python
當團隊中多人協同開發同一個功能時,可能存在開發人員之間的版本互相覆蓋問題。linux
協同修改git
對人能夠並行地修改同一個文件。github
數據備份算法
不只保存數據當前地實際狀態,還能保存文件提交地歷史狀態,能夠回滾操做。centos
版本管理緩存
保存版本時不保存重複數據,節約存儲,提升運行效率。bash
權限控制服務器
對團隊中參與開發的人員進行權限控制,對其餘開發人員貢獻的代碼進行審覈。ssh
歷史記錄
查看提交修改歷史,版本回滾
分支管理
容許開發團隊在工做過程當中多條生產線同時推動任務,提升效率。
集中式:SVN、CVS、VSS。以服務器爲核心,容易出現單點故障問題。
分佈式:GIT、Mercurial、Bazaar、Darcs,避免了單點故障。
git init //在目錄中將建立一個.git目錄
設置一個用戶信息,用於惟一標示身份,僅用於區分開發人員,信息和遠程倉庫無關。
簽名分爲項目級別和系統級別,簽名的做用域不一樣,項目/倉庫級別在本倉庫中有效,優先使用倉庫級別。簽名必須設置才能執行操做。
git config user.name xxx git config user.email xxx@xxx.com git config --global user.name xxx git config user.email xxx@xxx.com
$ cat ~/.gitconfig [user] email = 1958862281@qq.com name = Wan9huan //全局簽名存儲在全局配置文件中 //倉庫簽名保存在.git/config中
git status #查看狀態 git add #添加文件到緩存區 git remove --cached #移除已經add的文件 git commit #提交 git commit -a -m"This is Message" #提交附帶註釋 git log #查看日誌 git log --oneline #簡潔查看 git relog #查看日誌和回滾步數 git reset --hard HEAD^ #後退一步 git reset --hard HEAD~3 #後退三步 git reset --hard 2fedc85 #回到指定版本 ------------------------------------------------------------------------ $ git status On branch master No commits yet nothing to commit (create/copy files and use "git add" to track) ------------------------------------------------------------------------ $ git status On branch master Untracked files: (use "git add <file>..." to include in what will be committed) ReactDemo/ 2017-09-07.png nothing added to commit but untracked files present (use "git add" to track) ------------------------------------------------------------------------ $ git add 2017-09-07.png $ git status On branch master No commits yet Changes to be committed: (use "git rm --cached <file>..." to unstage) // 從緩存區移除 new file: 2017-09-07.png Untracked files: (use "git add <file>..." to include in what will be committed) ------------------------------------------------------------------------ $ git commit [master (root-commit) c40dd30] Changes to be committed: new file: 2017-09-07.png //版本號 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 2017-09-07.png ----------------------------------------------------------------------- $ git status On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working tree clean ------------------------------------------------------------------------ $ git log --oneline 8b6ba42 (HEAD -> master) Create A Book Text 37c34e8 deleted: Photoshop_Set-Up.exe 4cfa483 (origin/master) last a2858e8 new 4b3e03e aa dc03544 Merge branch 'master' of https://github.com/wan9huan/myfiles 9b3d010 all 9382437 Delete background.png bb31bd9 Changes to be committed: new file: icon 2.png b386c61 a 4366632 a fc86b6a png for background ------------------------------------------------------------------------ $ git reflog 8b6ba42 (HEAD -> master) HEAD@{0}: commit: Create A Book Text 37c34e8 HEAD@{1}: commit: deleted: Photoshop_Set-Up.exe 4cfa483 (origin/master) HEAD@{2}: commit: last a2858e8 HEAD@{3}: commit: new 4b3e03e HEAD@{4}: commit: aa dc03544 HEAD@{5}: pull: Merge made by the 'recursive' strategy. 9b3d010 HEAD@{6}: commit: all bb31bd9 HEAD@{7}: commit: Changes to be committed: b386c61 HEAD@{8}: commit: a 4366632 HEAD@{9}: commit: a fc86b6a HEAD@{10}: commit (initial): png for background ------------------------------------------------------------------------ $ git reflog book.txt 5997266 (HEAD -> master) HEAD@{0}: commit: 第四次修改 2fedc85 HEAD@{1}: commit: 第三次修改 af72196 HEAD@{2}: commit: add a string 8b6ba42 HEAD@{3}: commit: Create A Book Text ------------------------------------------------------------------------ //回滾、回到指定版本 $ git reflog book.txt 5997266 (HEAD -> master) HEAD@{0}: commit: 第四次修改 2fedc85 HEAD@{1}: commit: 第三次修改 af72196 HEAD@{2}: commit: add a string 8b6ba42 HEAD@{3}: commit: Create A Book Text $ cat book.txt This is a Book Text 333333333333333 444444444444444 $ git reset --hard af72196 HEAD is now at af72196 add a string $ cat book.txt This is a Book Text $ git reset --hard 2fedc85 HEAD is now at 2fedc85 第三次修改 $ cat book.txt This is a Book Text 333333333333333 ------------------------------------------------------------------------ $ git reset --hard HEAD^ 後退一步 $ git reset --hard HEAD~3 後退三步
git rest --soft #移動本地庫指針 git rest --mixed #移動本地庫、重置暫存區 git rest --hard #移動本地庫、重置暫存區、重置工做區
git diff #暫存區比較 git diff Head #比較某一版本 ------------------------------------------------------------------------ $ git diff book.txt diff --git a/book.txt b/book.txt index 48d8508..f2259a8 100644 --- a/book.txt +++ b/book.txt @@ -1,2 +1,4 @@ This is a Book Text -333333333333333 \ No newline at end of file +333333333333333 +444444444444444 +555555555555555 \ No newline at end of file
git status #查看當前分支 git branch -v #查看全部分支 git branch xxx #建立分支 git checkout xxx #切換分支 ------------------------------------------------------------------------ $ git status -v On branch master //主分支 Your branch is ahead of 'origin/master' by 5 commits. (use "git push" to publish your local commits) nothing to commit, working tree clean $ git branch -v * master 828b1ab [ahead 5] commit all $ git branch hot_fix $ git checkout hot_fix Switched to branch 'hot_fix' ------------------------------------------------------------------------ #分支合併 1.切換到主分支 2.執行 git merge xxxx -------------------------------------------------------------------------------- git checkout xxxx git merge xxxx ------------------------------------------------------------------------
git remote -v #查看遠程倉庫 git remote add(remove) xxx ht..com/xxx.git #添加遠程倉庫 git push xxx master(填寫推送分支) #推送到分支 git clone https://git....../xxx/git #克隆遠程庫 git fetch xxx master #下載遠程內容 git checkout xxx/master #切換到某個遠程分支 git checkout master #切換到本地分支 git merge xxx/maser #合併本地和遠程 git pull #直接合並遠程到本地 ------------------------------------------------------------------------ $ git remote -v origin https://github.com/wan9huan/myfiles.git (fetch) origin https://github.com/wan9huan/myfiles.git (push) $ git push origin master Enumerating objects: 15, done. Counting objects: 100% (15/15), done. Delta compression using up to 4 threads. Compressing objects: 100% (11/11), done. Writing objects: 100% (14/14), 1.22 KiB | 138.00 KiB/s, done. Total 14 (delta 5), reused 0 (delta 0) remote: Resolving deltas: 100% (5/5), completed with 1 local object. To https://github.com/wan9huan/myfiles.git 4cfa483..828b1ab master -> master ------------------------------------------------------------------------ #必須是遠程倉庫的成員才能夠進行推送
#當不是基於最新版作出的修改沒法進行推送 #拉去遠程資源進入衝突解決狀態,解決衝突 #提交再推送便可成功完成推送操做
ssh-keygen -t rsa -C|github帳號 # 生成 .ssh/ 目錄 生成 id_rsa id_rsa.pub # 將公鑰添加到遠程端 git remote add xxxx ssh版本的.git git push xxxx master #使用 ssh push
yum -y install policycoreutils openssh-server openssh-clients postfix policycoreutils-python #啓動項 systemctl enable postfix && systemctl start postfix
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum #選擇一個安裝包 wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.0.6-ce.0.el7.x86_64.rpm #選擇本身的安裝包 e16 centos6 e17 centos7 rpm -i gitlab-ce-11.0.6-ce.0.el7.x86_64.rpm *. *. *** *** ***** ***** .****** ******* ******** ******** ,,,,,,,,,***********,,,,,,,,, ,,,,,,,,,,,*********,,,,,,,,,,, .,,,,,,,,,,,*******,,,,,,,,,,,, ,,,,,,,,,*****,,,,,,,,,. ,,,,,,,****,,,,,, .,,,***,,,, ,*,. _______ __ __ __ / ____(_) /_/ / ____ _/ /_ / / __/ / __/ / / __ `/ __ \ / /_/ / / /_/ /___/ /_/ / /_/ / \____/_/\__/_____/\__,_/_.___/ Thank you for installing GitLab! gitlab-ctl reconfigure //須要等待較長時間 gitlab-clt restart
哈希加密算法,無論運算前的數據有多大,進行哈希運算後,能獲得固定長度的加密結果,一樣的數據通過相同的算法,都能輸出一樣的結果,不一樣的數據獲得同一個哈希值的可能性極小,不可逆。
數據保存爲小型文件系統的一組快照,建立分支時,新建一個指向當前版本的指針。