亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長(zhǎng)資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    使用Git與GitHub協(xié)同開(kāi)發(fā)并搭建私有GitLab代碼托管服務(wù)器

    Git的發(fā)展史

    Linus在1991年創(chuàng)建了開(kāi)源的Linux,從此全世界的工程師參與了Linux的開(kāi)發(fā),期初Linus是通過(guò)手動(dòng)diff的方式進(jìn)行代碼審核和合并的,后來(lái)BitKeeper的東家BitMover公司出于人道主義精神,授權(quán)Linux社區(qū)免費(fèi)使用這個(gè)版本控制系統(tǒng)。安定團(tuán)結(jié)的大好局面在2005年就被打破了,原因是Linux社區(qū)牛人聚集,不免沾染了一些梁山好漢的江湖習(xí)氣。開(kāi)發(fā)Samba的Andrew試圖破解BitKeeper的協(xié)議(這么干的其實(shí)也不只他一個(gè)),被BitMover公司發(fā)現(xiàn)了(監(jiān)控工作做得不錯(cuò)?。谑?code>BitMover公司怒了,要收回Linux社區(qū)的免費(fèi)使用權(quán)。Linus花了兩周時(shí)間自己用C寫(xiě)了一個(gè)分布式版本控制系統(tǒng),這就是Git!一個(gè)月之內(nèi),Linux系統(tǒng)的源碼已經(jīng)由Git管理了!如果當(dāng)時(shí)BitMover公司專(zhuān)門(mén)為Linux發(fā)布一個(gè)社區(qū)版,也許這家公司也就名垂青史了,可是當(dāng)時(shí)這家公司思想境界沒(méi)那么高而且Linus也那么牛!

    Ubuntu安裝Git

    niko@niko-notebook:~$ sudo apt install git -y

    Windows安裝Git

    基本就是一路Next最后Finsh。

    同一團(tuán)隊(duì)協(xié)作開(kāi)發(fā)

    假定存在用戶(hù)A和用戶(hù)B,用戶(hù)A創(chuàng)建了一個(gè)遠(yuǎn)程倉(cāng)庫(kù),然后遠(yuǎn)程倉(cāng)庫(kù)clone到本地,進(jìn)行開(kāi)發(fā)完成以后push到遠(yuǎn)程倉(cāng)庫(kù)。同時(shí)用戶(hù)B也在開(kāi)發(fā)這個(gè)項(xiàng)目,首先用戶(hù)B將遠(yuǎn)程倉(cāng)庫(kù)clone到本地進(jìn)行開(kāi)發(fā),完成后push到遠(yuǎn)程倉(cāng)庫(kù),同時(shí)用戶(hù)A再pull遠(yuǎn)程倉(cāng)庫(kù)代碼同步項(xiàng)目。

    使用Git與GitHub協(xié)同開(kāi)發(fā)并搭建私有GitLab代碼托管服務(wù)器

    跨團(tuán)隊(duì)協(xié)作開(kāi)發(fā)

    假定存在兩個(gè)開(kāi)發(fā)團(tuán)隊(duì)A和B,開(kāi)發(fā)團(tuán)隊(duì)A的每個(gè)成員都擁有一個(gè)本地版本庫(kù),但是需要開(kāi)發(fā)團(tuán)隊(duì)B協(xié)助開(kāi)發(fā),那么開(kāi)發(fā)團(tuán)隊(duì)會(huì)先f(wàn)ork一個(gè)遠(yuǎn)程倉(cāng)庫(kù),接著開(kāi)發(fā)團(tuán)隊(duì)B的成員分別clone副本遠(yuǎn)程倉(cāng)庫(kù)到本地進(jìn)行開(kāi)發(fā),然后push到副本遠(yuǎn)程倉(cāng)庫(kù)。完成后,開(kāi)發(fā)團(tuán)隊(duì)B向開(kāi)發(fā)團(tuán)隊(duì)A發(fā)出一個(gè)pull request請(qǐng)求,項(xiàng)目通過(guò)審核之后開(kāi)發(fā)團(tuán)隊(duì)A再merge副本庫(kù)到原始遠(yuǎn)程庫(kù),完成功能合并。
    使用Git與GitHub協(xié)同開(kāi)發(fā)并搭建私有GitLab代碼托管服務(wù)器

    使用Git命令行

    • 使用git init命令初始化一個(gè)新的項(xiàng)目

    niko@niko-notebook:~$ git init StudyGit
    Initialized empty Git repository in /home/niko/StudyGit/.git/

    • 使用git init命令開(kāi)始管理一個(gè)現(xiàn)有的項(xiàng)目

    niko@niko-notebook:~$ mkdir StydyGit
    niko@niko-notebook:~$ cd StydyGit/
    niko@niko-notebook:~/StydyGit$ git init
    Initialized empty Git repository in /home/niko/StydyGit/.git/

    • 使用Git管理一個(gè)項(xiàng)目的時(shí)候會(huì)創(chuàng)建一下文件和目錄

    niko@niko-notebook:~$ tree StudyGit -a
    StudyGit
    └── .git
      ├── HEAD
      ├── branches
      ├── config
      ├── description
      ├── hooks
      │  ├── applypatch-msg.sample
      │  ├── commit-msg.sample
      │  ├── fsmonitor-watchman.sample
      │  ├── post-update.sample
      │  ├── pre-applypatch.sample
      │  ├── pre-commit.sample
      │  ├── pre-push.sample
      │  ├── pre-rebase.sample
      │  ├── pre-receive.sample
      │  ├── prepare-commit-msg.sample
      │  └── update.sample
      ├── info
      │  └── exclude
      ├── objects
      │  ├── info
      │  └── pack
      └── refs
          ├── heads
          └── tags

    10 directories, 15 files

    在Git中有4個(gè)區(qū),分別是工作區(qū)、暫存區(qū)、本地庫(kù)、遠(yuǎn)程庫(kù)。我們項(xiàng)目開(kāi)發(fā)就是在工作區(qū)工作,然后使用git add命令將工作區(qū)的代碼提交到暫存區(qū),使用git commit命令將暫存區(qū)的文件提交到本地庫(kù)。Git的有一個(gè)代碼托管中心是GitHub,同樣國(guó)內(nèi)還有Google Code,碼云等。

    • 設(shè)置Git簽名

      項(xiàng)目級(jí)別(本地)

      niko@niko-notebook:~/StydyGit$ git config user.name niko
      niko@niko-notebook:~/StydyGit$ git config user.email niko@163.com

      系統(tǒng)級(jí)別(全局)

      niko@niko-notebook:~/StydyGit$ git config –global user.name xvge
      niko@niko-notebook:~/StydyGit$ git config –global user.email xvge@163.com

      簽名優(yōu)先級(jí)

      就近原則:項(xiàng)目?jī)?yōu)先級(jí)高于系統(tǒng)優(yōu)先級(jí)

      項(xiàng)目級(jí)別的配置信息存放到項(xiàng)目目錄的.git/config文件中:

    niko@niko-notebook:~/StydyGit$ cat .git/config[core]
          repositoryformatversion = 0
          filemode = true
          bare = false
          logallrefupdates = true
    [user]
          name = niko
          email = niko@163.com

    • 項(xiàng)目級(jí)別的配置信息存放到系統(tǒng)用戶(hù)目錄的.gitconfig文件中:

    niko@niko-notebook:~/StydyGit$ cat ~/.gitconfig[user]
          name = xvge
          email = xvge@163.com

    • 查看當(dāng)前工作區(qū)的狀態(tài)(git status

      niko@niko-notebook:~/StydyGit$ git status  On branch master   # 當(dāng)前所處的分支    No commits yet    nothing to commit (create/copy files and use "git add" to track)

      當(dāng)創(chuàng)建一個(gè)新文件的時(shí)候,這個(gè)新的文件處于未被跟蹤的狀態(tài):

      niko@niko-notebook:~/StydyGit$ echo "Hello, Git." > file.txt  # 創(chuàng)建一個(gè)文件  niko@niko-notebook:~/StydyGit$ git status  On branch master    No commits yet    Untracked files:   # 列出未被追蹤的文件  (use "git add <file>..." to include in what will be committed)          file.txt    nothing added to commit but untracked files present (use "git add" to track)
    • 將工作區(qū)的文件提交到暫存區(qū),使得Git可以跟蹤新文件(git add

      niko@niko-notebook:~/StydyGit$ git add .  niko@niko-notebook:~/StydyGit$ git status  On branch master    No commits yet    Changes to be committed:    # 列出更改的文件  (use "git rm --cached <file>..." to unstage)          new file:   file.txt
    • 將暫存區(qū)的文件提交到本地庫(kù)(git commit

      niko@niko-notebook:~/StydyGit$ git commit -m "add file.txt"  [master (root-commit) 5f9adfe] add file.txt   1 file changed, 1 insertion(+)   create mode 100644 file.txt
    • 查看提交日志(git log

      niko@niko-notebook:~/StydyGit$ git log  commit e6442a41c339e0fd6d01656cbea24775471ee1ed (HEAD -> master)  # HEAD表示當(dāng)前版本  Author: niko <niko@163.com>  Date:   Mon Sep 24 12:34:38 2018 +0800        modifiy file.txt  # 提交的注釋信息    commit 5f9adfeade857255ef647f855899965274a5fe95   # 40為16進(jìn)制SHA-256值  Author: niko <niko@163.com>  Date:   Mon Sep 24 12:16:20 2018 +0800        add file.txt
    • 查看提交日志(git log

      多次修改后的git log

      niko@niko-notebook:~/StydyGit$ git log  commit b4a54420dcea8d480b80797e032d8ed74b430a97 (HEAD -> master)  Author: niko <niko@163.com>  Date:   Mon Sep 24 12:40:27 2018 +0800        modifiy file.txt    commit 17acb2424f04c7ec0298e0c59039d19bce8369b6  Author: niko <niko@163.com>  Date:   Mon Sep 24 12:39:08 2018 +0800        add file3.txt    commit 80cbf7f5c44e0507439bd97a8976d28b746f4f45  Author: niko <niko@163.com>  Date:   Mon Sep 24 12:38:26 2018 +0800        add file2.txt    commit e6442a41c339e0fd6d01656cbea24775471ee1ed  Author: niko <niko@163.com>  Date:   Mon Sep 24 12:34:38 2018 +0800        modifiy file.txt    commit 5f9adfeade857255ef647f855899965274a5fe95  Author: niko <niko@163.com>  Date:   Mon Sep 24 12:16:20 2018 +0800        add file.txt

      使用git log --pretty=oneline

      niko@niko-notebook:~/StydyGit$ git log --pretty=oneline  b4a54420dcea8d480b80797e032d8ed74b430a97 (HEAD -> master) modifiy file.txt  17acb2424f04c7ec0298e0c59039d19bce8369b6 add file3.txt  80cbf7f5c44e0507439bd97a8976d28b746f4f45 add file2.txt  e6442a41c339e0fd6d01656cbea24775471ee1ed modifiy file.txt  5f9adfeade857255ef647f855899965274a5fe95 add file.txt

      使用git log --oneline

      niko@niko-notebook:~/StydyGit$ git log --oneline  b4a5442 (HEAD -> master) modifiy file.txt  17acb24 add file3.txt  80cbf7f add file2.txt  e6442a4 modifiy file.txt  5f9adfe add file.txt

      使用git reflog

      niko@niko-notebook:~/StydyGit$ git reflog  b4a5442 (HEAD -> master) HEAD@{0}: commit: modifiy file.txt  17acb24 HEAD@{1}: commit: add file3.txt  80cbf7f HEAD@{2}: commit: add file2.txt  e6442a4 HEAD@{3}: commit: modifiy file.txt  5f9adfe HEAD@{4}: commit (initial): add file.txt
    • 版本回退(git reset

      參數(shù):

      git reset –soft 回退本地庫(kù)
      git reset –mixed 默認(rèn),回退暫存區(qū)、本地庫(kù)
      git reset –hard 回退暫存區(qū)、工作區(qū)、本地庫(kù)

      niko@niko-notebook:~/StydyGit$ git reset 80cbf7f

      git reset --soft圖示

    使用Git與GitHub協(xié)同開(kāi)發(fā)并搭建私有GitLab代碼托管服務(wù)器

    git reset --mixed圖示

    使用Git與GitHub協(xié)同開(kāi)發(fā)并搭建私有GitLab代碼托管服務(wù)器

    git reset --hard圖示

    使用Git與GitHub協(xié)同開(kāi)發(fā)并搭建私有GitLab代碼托管服務(wù)器

    • 找回文件(git reset

    niko@niko-notebook:~/StydyGit$ ls    # 查看file2.txt文件是否存在
    file.txt  file2.txt  file3.txt
    niko@niko-notebook:~/StydyGit$ rm -rf file2.txt  # 刪除file2.txt文件
    niko@niko-notebook:~/StydyGit$ ls  # 確保file2.txt文件已經(jīng)刪除
    file.txt  file3.txt
    niko@niko-notebook:~/StydyGit$ git status  # 查看文件跟蹤狀態(tài)
    On branch master
    Changes not staged for commit:
    (use “git add/rm <file>…” to update what will be committed)
    (use “git checkout — <file>…” to discard changes in working directory)

          deleted:    file2.txt

    no changes added to commit (use “git add” and/or “git commit -a”)
    niko@niko-notebook:~/StydyGit$ git add .  # 跟蹤當(dāng)前狀態(tài)
    niko@niko-notebook:~/StydyGit$ git commit -m “del file2.txt”  # 將代碼提交到本地庫(kù)
    [master db6e563] del file2.txt
    1 file changed, 1 deletion(-)
    delete mode 100644 file2.txt
    niko@niko-notebook:~/StydyGit$ git reflog  # 查看形成一個(gè)版本信息db6e563
    db6e563 (HEAD -> master) HEAD@{0}: commit: del file2.txt
    bcf8ce2 HEAD@{1}: commit: first reset
    80cbf7f HEAD@{2}: reset: moving to 80cbf7f
    b4a5442 HEAD@{3}: commit: modifiy file.txt
    17acb24 HEAD@{4}: commit: add file3.txt
    80cbf7f HEAD@{5}: commit: add file2.txt
    e6442a4 HEAD@{6}: commit: modifiy file.txt
    5f9adfe HEAD@{7}: commit (initial): add file.txt
    niko@niko-notebook:~/StydyGit$ git reset –hard bcf8ce2  # 回退到上一個(gè)版本
    HEAD is now at bcf8ce2 first reset
    niko@niko-notebook:~/StydyGit$ ls    # file2.txt文件已經(jīng)存在
    file.txt  file2.txt  file3.txt
    niko@niko-notebook:~/StydyGit$ git status    # 查看當(dāng)前跟蹤狀態(tài)
    On branch master
    nothing to commit, working tree clean
    niko@niko-notebook:~/StydyGit$ git reflog  # 生成一個(gè)版本信息
    bcf8ce2 (HEAD -> master) HEAD@{0}: reset: moving to bcf8ce2
    db6e563 HEAD@{1}: commit: del file2.txt
    bcf8ce2 (HEAD -> master) HEAD@{2}: commit: first reset
    80cbf7f HEAD@{3}: reset: moving to 80cbf7f
    b4a5442 HEAD@{4}: commit: modifiy file.txt
    17acb24 HEAD@{5}: commit: add file3.txt
    80cbf7f HEAD@{6}: commit: add file2.txt
    e6442a4 HEAD@{7}: commit: modifiy file.txt
    5f9adfe HEAD@{8}: commit (initial): add file.txt

    • git diff

    使用git diff –staged比較工作區(qū)與暫存區(qū)的不同。

    使用git diff –cached比較暫存區(qū)與本地庫(kù)的不同。

    分支管理

    分支可以并行推進(jìn)項(xiàng)目的開(kāi)發(fā),開(kāi)發(fā)的某一個(gè)功能如果失敗不會(huì)影響項(xiàng)目整體。

    使用Git與GitHub協(xié)同開(kāi)發(fā)并搭建私有GitLab代碼托管服務(wù)器

    • 查看分支(git branch -v

      niko@niko-notebook:~/StydyGit$ git branch -v  * master bcf8ce2 first reset
    • 創(chuàng)建分支(git branch branchName

      niko@niko-notebook:~/StydyGit$ git branch hot_fix
    • 切換分支(git checkout branchName

      niko@niko-notebook:~/StydyGit$ git checkout hot_fix  Switched to branch 'hot_fix'  niko@niko-notebook:~/StydyGit$ git branch -v   # 星號(hào)所在分支就是當(dāng)前分支  * hot_fix bcf8ce2 first reset  master  bcf8ce2 first reset
    • 合并分支(git merge branchName

    niko@niko-notebook:~/StydyGit$ vim file3.txt  # 修改文件
    niko@niko-notebook:~/StydyGit$ git status      # 查看分支狀態(tài)
    On branch hot_fix
    Changes not staged for commit:
    (use “git add <file>…” to update what will be committed)
    (use “git checkout — <file>…” to discard changes in working directory)

          modified:  file3.txt

    no changes added to commit (use “git add” and/or “git commit -a”)
    niko@niko-notebook:~/StydyGit$ git add .      # 添加到當(dāng)前分支的跟蹤狀態(tài)
    niko@niko-notebook:~/StydyGit$ git commit -m “fix bug by xvge”  # 提交代碼
    [hot_fix 40376b9] fix bug by xvge
    1 file changed, 1 insertion(+)
    niko@niko-notebook:~/StydyGit$ git checkout master  # 切換到主分支
    Switched to branch ‘master’
    niko@niko-notebook:~/StydyGit$ git merge hot_fix    # 將hot_fix合并到master
    Updating bcf8ce2..40376b9
    Fast-forward
    file3.txt | 1 +
    1 file changed, 1 insertion(+)
    niko@niko-notebook:~/StydyGit$ git stataus        # 查看主分支狀態(tài)
    git: ‘stataus’ is not a git command. See ‘git –help’.

    The most similar command is
          status
    niko@niko-notebook:~/StydyGit$ git status
    On branch master
    nothing to commit, working tree clean
    niko@niko-notebook:~/StydyGit$ git reflog  # 產(chǎn)生幾個(gè)新版本
    40376b9 (HEAD -> master, hot_fix) HEAD@{0}: merge hot_fix: Fast-forward
    bcf8ce2 HEAD@{1}: checkout: moving from hot_fix to master
    40376b9 (HEAD -> master, hot_fix) HEAD@{2}: commit: fix bug by xvge
    bcf8ce2 HEAD@{3}: checkout: moving from master to hot_fix
    bcf8ce2 HEAD@{4}: reset: moving to bcf8ce2
    db6e563 HEAD@{5}: commit: del file2.txt
    bcf8ce2 HEAD@{6}: commit: first reset
    80cbf7f HEAD@{7}: reset: moving to 80cbf7f
    b4a5442 HEAD@{8}: commit: modifiy file.txt
    17acb24 HEAD@{9}: commit: add file3.txt
    80cbf7f HEAD@{10}: commit: add file2.txt
    e6442a4 HEAD@{11}: commit: modifiy file.txt
    5f9adfe HEAD@{12}: commit (initial): add file.txt

      • 合并代碼時(shí)產(chǎn)生了沖突

    # 修改master分支代碼
    niko@niko-notebook:~/StydyGit$ git branch -v
    hot_fix 40376b9 fix bug by xvge
    * master  40376b9 fix bug by xvge
    niko@niko-notebook:~/StydyGit$ vim file3.txt
    niko@niko-notebook:~/StydyGit$ git add .
    niko@niko-notebook:~/StydyGit$ git commit -m “add festure by master”
    [master cbd7ce1] add festure by master
    1 file changed, 1 insertion(+)
    # 修改hot_fix分支代碼
    niko@niko-notebook:~/StydyGit$ git branch -v
    * hot_fix 40376b9 fix bug by xvge
    master  40376b9 fix bug by xvge
    niko@niko-notebook:~/StydyGit$ vim file3.txt
    niko@niko-notebook:~/StydyGit$ git add .
    niko@niko-notebook:~/StydyGit$ git commit -m “add feature by fix”
    [hot_fix 6cceae3] add feature by fix
    1 file changed, 1 insertion(+)
    # 將master合并到hot_fix上
    niko@niko-notebook:~/StydyGit$ git branch -v
    * hot_fix 6cceae3 add feature by fix
    master  cbd7ce1 add festure by master
    niko@niko-notebook:~/StydyGit$ git merge master
    Auto-merging file3.txt
    CONFLICT (content): Merge conflict in file3.txt
    Automatic merge failed; fix conflicts and then commit the result.
    # 解決沖突
    niko@niko-notebook:~/StydyGit$ vim file3.txt
    Hi, FullStackDev.
    fix this bug by xvge.
    <<<<<<< HEAD
    add festure by fix.
    =======
    add feature by master.
    >>>>>>> master
    # 提×××并
    niko@niko-notebook:~/StydyGit$ git add .
    niko@niko-notebook:~/StydyGit$ git commit -m “merge code by conflict”
    [hot_fix 088f6c5] merge code by conflict

    Git與GitHub遠(yuǎn)程倉(cāng)庫(kù)交互

    • 創(chuàng)建遠(yuǎn)程倉(cāng)庫(kù)github.com,如果勾選Initialize this repository with a README選項(xiàng)可能首次推送失敗。

    使用Git與GitHub協(xié)同開(kāi)發(fā)并搭建私有GitLab代碼托管服務(wù)器

    • 將GitHub地址保存到本地

    niko@niko-notebook:~/StydyGit$ git remote add origin https://github.com/xvGe/StudyGit.git

    • 查看本地保存了什么地址

    niko@niko-notebook:~/StydyGit$ git remote -v
    origin  https://github.com/xvGe/StudyGit.git (fetch)
    origin  https://github.com/xvGe/StudyGit.git (push)

    • 將本地庫(kù)推送到遠(yuǎn)程庫(kù)

    niko@niko-notebook:~/StydyGit$ git push origin master
    Username for ‘https://github.com’: xvGe
    Password for ‘https://xvGe@github.com’:
    Counting objects: 19, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (11/11), done.
    Writing objects: 100% (19/19), 1.44 KiB | 52.00 KiB/s, done.
    Total 19 (delta 2), reused 0 (delta 0)
    remote: Resolving deltas: 100% (2/2), done.
    remote:
    remote: Create a pull request for ‘master’ on GitHub by visiting:
    remote:      https://github.com/xvGe/StudyGit/pull/new/master
    remote:
    To https://github.com/xvGe/StudyGit.git
    * [new branch]      master -> master

    使用Git與GitHub協(xié)同開(kāi)發(fā)并搭建私有GitLab代碼托管服務(wù)器

    • 克隆遠(yuǎn)程庫(kù)(git clone

    niko@niko-notebook:~/StydyGit$ cd ../
    niko@niko-notebook:~$ rm -rf StydyGit/
    niko@niko-notebook:~$ git clone https://github.com/xvGe/StudyGit.git
    Cloning into ‘StudyGit’…
    remote: Counting objects: 19, done.
    remote: Compressing objects: 100% (9/9), done.
    remote: Total 19 (delta 2), reused 19 (delta 2), pack-reused 0
    Unpacking objects: 100% (19/19), done.

    • 拉取遠(yuǎn)程庫(kù)(git pullgit fetch

    niko@niko-notebook:~$ git init StudyGit2  # 創(chuàng)建新項(xiàng)目
    Initialized empty Git repository in /home/niko/StudyGit2/.git/
    niko@niko-notebook:~$ cd StudyGit2/  # 進(jìn)入項(xiàng)目目錄
    niko@niko-notebook:~/StudyGit2$ git remote add origin https://github.com/xvGe/StudyGit.git#添加地址
    niko@niko-notebook:~/StudyGit2$ git fetch origin master  # 拉取項(xiàng)目
    remote: Counting objects: 19, done.
    remote: Compressing objects: 100% (9/9), done.
    remote: Total 19 (delta 2), reused 19 (delta 2), pack-reused 0
    Unpacking objects: 100% (19/19), done.
    From https://github.com/xvGe/StudyGit
     * branch            master    -> FETCH_HEAD
     * [new branch]      master    -> origin/master
    niko@niko-notebook:~/StudyGit2$ git branch -a    # 查看所有分支
      remotes/origin/master
    niko@niko-notebook:~/StudyGit2$ git branch -r    # 查看遠(yuǎn)程分支
      origin/master
    niko@niko-notebook:~/StudyGit2$ git merge origin/master  # 合并分支
    niko@niko-notebook:~/StudyGit2$ ls
    file.txt  file2.txt  file3.txt
    niko@niko-notebook:~/StudyGit2$ cd ../    # 返回上層
    niko@niko-notebook:~$ git init StudyGit3  # 初始化一個(gè)項(xiàng)目
    Initialized empty Git repository in /home/niko/StudyGit3/.git/
    niko@niko-notebook:~$ cd StudyGit3/      # 進(jìn)入項(xiàng)目目錄
    niko@niko-notebook:~/StudyGit3$ git pull https://github.com/xvGe/StudyGit.git  # 拉取項(xiàng)目
    remote: Counting objects: 19, done.
    remote: Compressing objects: 100% (9/9), done.
    remote: Total 19 (delta 2), reused 19 (delta 2), pack-reused 0
    Unpacking objects: 100% (19/19), done.
    From https://github.com/xvGe/StudyGit
     * branch            HEAD      -> FETCH_HEAD
    niko@niko-notebook:~/StudyGit3$ ls
    file.txt  file2.txt  file3.txt

    git fetchgit pull的區(qū)別是,前者會(huì)創(chuàng)建新分支,需要合并操作,但是更加安全;后者直接修改本地代碼。

    跨團(tuán)隊(duì)協(xié)作

    • 遠(yuǎn)程克隆倉(cāng)庫(kù)

    使用Git與GitHub協(xié)同開(kāi)發(fā)并搭建私有GitLab代碼托管服務(wù)器

    • 團(tuán)隊(duì)拉取遠(yuǎn)程倉(cāng)庫(kù)修改并推送

    niko@niko-notebook:~$ git init StudyGitHub
    Initialized empty Git repository in /home/niko/StudyGitHub/.git/
    niko@niko-notebook:~$ cd StudyGitHub/
    niko@niko-notebook:~/StudyGitHub$ git pull https://github.com/xv-niko/StudyGit.git
    niko@niko-notebook:~/StudyGitHub$ git remote add origin https://github.com/xv-niko/StudyGit.git
    niko@niko-notebook:~/StudyGitHub$ ls
    file.txt  file2.txt  file3.txt
    niko@niko-notebook:~/StudyGitHub$ echo “Desgin by B” >> file3.txt
    niko@niko-notebook:~/StudyGitHub$ git add .
    niko@niko-notebook:~/StudyGitHub$ git commit -m “add code”
    [master 09003b9] add code
    1 file changed, 1 insertion(+)
    niko@niko-notebook:~/StudyGitHub$ git push origin master
    Username for ‘https://github.com’: xv-niko
    Password for ‘https://xv-niko@github.com’:
    Counting objects: 3, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (3/3), done.
    Writing objects: 100% (3/3), 274 bytes | 68.00 KiB/s, done.
    Total 3 (delta 2), reused 0 (delta 0)
    remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
    To https://github.com/xv-niko/StudyGit.git
     cbd7ce1..09003b9  master -> master

    • 發(fā)起pull requests

    使用Git與GitHub協(xié)同開(kāi)發(fā)并搭建私有GitLab代碼托管服務(wù)器

    使用Git與GitHub協(xié)同開(kāi)發(fā)并搭建私有GitLab代碼托管服務(wù)器

    使用Git與GitHub協(xié)同開(kāi)發(fā)并搭建私有GitLab代碼托管服務(wù)器

    • 項(xiàng)目所有者團(tuán)隊(duì)查看請(qǐng)求

    使用Git與GitHub協(xié)同開(kāi)發(fā)并搭建私有GitLab代碼托管服務(wù)器

    • 合并代碼

    使用Git與GitHub協(xié)同開(kāi)發(fā)并搭建私有GitLab代碼托管服務(wù)器

    • 所有者團(tuán)隊(duì)合并到本地

    niko@niko-notebook:~/StudyGitHub$ cd ../StudyGit
    niko@niko-notebook:~/StudyGit$ git pull origin master
    remote: Counting objects: 4, done.
    remote: Compressing objects: 100% (2/2), done.
    remote: Total 4 (delta 2), reused 3 (delta 2), pack-reused 0
    Unpacking objects: 100% (4/4), done.
    From https://github.com/xvGe/StudyGit
    * branch            master    -> FETCH_HEAD
     cbd7ce1..0ca0905  master    -> origin/master
    Updating cbd7ce1..0ca0905
    Fast-forward
    file3.txt | 1 +
    1 file changed, 1 insertion(+)
    niko@niko-notebook:~/StudyGit$ cat file3.txt
    Hi, FullStackDev.
    fix this bug by xvge.
    add feature by master.
    Desgin by B

    Git工作流

    • 集中式工作流
    • Git Flow(常用)

    使用Git與GitHub協(xié)同開(kāi)發(fā)并搭建私有GitLab代碼托管服務(wù)器

    • Forking工作流

    部署GitLab代碼托管服務(wù)器

    yum clean all && yum repolist all
    yum install -y curl policycoreutils-Python openssh-server
    systemctl enable sshd
    systemctl start sshd
    firewall-cmd –permanent –add-service=http  # 如果開(kāi)啟了防火墻執(zhí)行
    systemctl reload firewalld                  # 如果開(kāi)啟了防火墻執(zhí)行
    yum install postfix -y
    systemctl enable postfix
    systemctl start postfix
    curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | bash
    EXTERNAL_URL=”http://gitlab.example.com” yum install -y gitlab-ce
    gitlab-ctl reconfigure    # 配置服務(wù)器
    gitlab-ctl start          # 啟動(dòng)服務(wù)器

    訪問(wèn)服務(wù)器地址即可,GitLab服務(wù)器搭建指南:https://about.gitlab.com/installation/

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)