• 
    

      <address id="upfr9"><pre id="upfr9"><strike id="upfr9"></strike></pre></address>
      1. <address id="upfr9"><tr id="upfr9"></tr></address><dl id="upfr9"></dl>

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        一、安裝環(huán)境的介紹

        公司主營業(yè)務(wù):成都網(wǎng)站建設(shè)、網(wǎng)站設(shè)計、移動網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。創(chuàng)新互聯(lián)公司是一支青春激揚、勤奮敬業(yè)、活力青春激揚、勤奮敬業(yè)、活力澎湃、和諧高效的團隊。公司秉承以“開放、自由、嚴謹、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團隊有機會用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)公司推出崖州免費做網(wǎng)站回饋大家。

        Centos 6.7  x86_64   2.6.32-573.el6.x86_64   IP:192.168.159.129   #公司內(nèi)部測試服務(wù)器

        GitLab版本:9.1.2

        軟件包下載地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/

        二、安裝過程

        #rpm -ivh gitlab-ce-9.1.2-ce.0.el6.x86_64.rpm 
        Preparing...                ########################################### [100%]
           1:gitlab-ce              ########################################### [100%]
        hostname: Host name lookup failure
        
        
               *.                  *.
              ***                 ***
             *****               *****
            .******             *******
            ********            ********
           ,,,,,,,,,***********,,,,,,,,,
          ,,,,,,,,,,,*********,,,,,,,,,,,
          .,,,,,,,,,,,*******,,,,,,,,,,,,
              ,,,,,,,,,*****,,,,,,,,,.
                 ,,,,,,,****,,,,,,
                    .,,,***,,,,
                        ,*,.
        
             _______ __  __          __
            / ____(_) /_/ /   ____ _/ /_
           / / __/ / __/ /   / __ `/ __ \
          / /_/ / / /_/ /___/ /_/ / /_/ /
          \____/_/\__/_____/\__,_/_.___/
        
        
        gitlab: Thank you for installing GitLab!
        gitlab: To configure and start GitLab, RUN THE FOLLOWING COMMAND:
        
        sudo gitlab-ctl reconfigure
        
        gitlab: GitLab should be reachable at http://gitlab.example.com
        gitlab: Otherwise configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
        gitlab: And running reconfigure again.
        gitlab: 
        gitlab: For a comprehensive list of configuration options please see the Omnibus GitLab readme
        gitlab: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
        gitlab: 
        It looks like GitLab has not been configured yet; skipping the upgrade script.
        根據(jù)上面的提示執(zhí)行:
        #sudo gitlab-ctl reconfigure
        Starting Chef Client, version 12.12.15
        resolving cookbooks for run list: ["gitlab"]
        Synchronizing Cookbooks:
          - gitlab (0.0.1)
          - package (0.0.0)
          - runit (0.14.2)
        Installing Cookbook Gems:
        Compiling Cookbooks...
        Recipe: gitlab::default
          * directory[/etc/gitlab] action create
            - change mode from '0755' to '0775'
        init (upstart 0.6.5)
          Converging 378 resources
          * directory[/etc/gitlab] action create (up to date)
          * directory[Create /var/opt/gitlab] action create
            - create new directory /var/opt/gitlab
            - change mode from '' to '0755'
            - change owner from '' to 'root'
            - change group from '' to 'root'
          * directory[/opt/gitlab/embedded/etc] action create
            - create new directory /opt/gitlab/embedded/etc
            - change mode from '' to '0755'
            - change owner from '' to 'root'
            - change group from '' to 'root'
          * template[/opt/gitlab/embedded/etc/gitconfig] action create
            - create new file /opt/gitlab/embedded/etc/gitconfig
            - update content in file /opt/gitlab/embedded/etc/gitconfig from none to 5fe039
            --- /opt/gitlab/embedded/etc/gitconfig      2017-05-25 10:46:30.027207736 +0800
            +++ /opt/gitlab/embedded/etc/.chef-gitconfig20170525-6666-jc6wi6    2017-05-25 10:46:30.026207736 +0800
            @@ -1 +1,10 @@
            +[pack]
            +  threads = 1
            +[receive]
            +  fsckObjects = true
            +[repack]
            +  writeBitmaps = true
            +[transfer]
            +  hideRefs=^refs/tmp/
            +hideRefs=^refs/keep-around/
            - change mode from '' to '0755'
        Recipe: gitlab::web-server
          * group[Webserver user and group] action create
            - create group gitlab-www
          * user[Webserver user and group] action create
            - create user gitlab-www
        Recipe: gitlab::users
        ………………………………                        #會輸出很多初始化的信息
            +
            - change owner from '' to 'root'
            - change group from '' to 'root'
          * ruby_block[reload gitlab-monitor svlogd configuration] action nothing (skipped due to action :nothing)
          * file[/opt/gitlab/sv/gitlab-monitor/down] action delete (up to date)
          * link[/opt/gitlab/init/gitlab-monitor] action create
            - create symlink at /opt/gitlab/init/gitlab-monitor to /opt/gitlab/embedded/bin/sv
          * link[/opt/gitlab/service/gitlab-monitor] action create
            - create symlink at /opt/gitlab/service/gitlab-monitor to /opt/gitlab/sv/gitlab-monitor
          * ruby_block[supervise_gitlab-monitor_sleep] action run
            - execute the ruby block supervise_gitlab-monitor_sleep
          * service[gitlab-monitor] action nothing (skipped due to action :nothing)
          * execute[/opt/gitlab/bin/gitlab-ctl start gitlab-monitor] action run
            [execute] ok: run: gitlab-monitor: (pid 7720) 1s
            - execute /opt/gitlab/bin/gitlab-ctl start gitlab-monitor
        Recipe: gitlab::default
          * link[/opt/gitlab/service/gitlab-git-http-server] action delete (up to date)
          * directory[/opt/gitlab/sv/gitlab-git-http-server] action delete (up to date)
        Recipe: gitlab::gitlab-rails
          * execute[clear the gitlab-rails cache] action run
            - execute /opt/gitlab/bin/gitlab-rake cache:clear
        Recipe: gitlab::redis
          * ruby_block[reload redis svlogd configuration] action create
            - execute the ruby block reload redis svlogd configuration
        Recipe: gitlab::postgresql
          * ruby_block[reload postgresql svlogd configuration] action create
            - execute the ruby block reload postgresql svlogd configuration
        Recipe: gitlab::unicorn
          * ruby_block[reload unicorn svlogd configuration] action create
            - execute the ruby block reload unicorn svlogd configuration
        Recipe: gitlab::sidekiq
          * ruby_block[reload sidekiq svlogd configuration] action create
            - execute the ruby block reload sidekiq svlogd configuration
        Recipe: gitlab::gitaly
          * service[gitaly] action restart
            - restart service service[gitaly]
          * ruby_block[reload gitaly svlogd configuration] action create
            - execute the ruby block reload gitaly svlogd configuration
        Recipe: gitlab::gitlab-workhorse
          * service[gitlab-workhorse] action restart
            - restart service service[gitlab-workhorse]
          * ruby_block[reload gitlab-workhorse svlogd configuration] action create
            - execute the ruby block reload gitlab-workhorse svlogd configuration
        Recipe: gitlab::nginx
          * ruby_block[reload nginx svlogd configuration] action create
            - execute the ruby block reload nginx svlogd configuration
        Recipe: gitlab::logrotate
          * ruby_block[reload logrotate svlogd configuration] action create
            - execute the ruby block reload logrotate svlogd configuration
        Recipe: gitlab::prometheus
          * service[prometheus] action restart
            - restart service service[prometheus]
          * ruby_block[reload prometheus svlogd configuration] action create
            - execute the ruby block reload prometheus svlogd configuration
        Recipe: gitlab::node-exporter
          * ruby_block[reload node-exporter svlogd configuration] action create
            - execute the ruby block reload node-exporter svlogd configuration
        Recipe: gitlab::redis-exporter
          * ruby_block[reload redis-exporter svlogd configuration] action create
            - execute the ruby block reload redis-exporter svlogd configuration
        Recipe: gitlab::postgres-exporter
          * service[postgres-exporter] action restart
            - restart service service[postgres-exporter]
          * ruby_block[reload postgres-exporter svlogd configuration] action create
            - execute the ruby block reload postgres-exporter svlogd configuration
        Recipe: gitlab::gitlab-monitor
          * service[gitlab-monitor] action restart
            - restart service service[gitlab-monitor]
          * ruby_block[reload gitlab-monitor svlogd configuration] action create
            - execute the ruby block reload gitlab-monitor svlogd configuration
        
        Running handlers:
        Running handlers complete
        Chef Client finished, 325/427 resources updated in 03 minutes 29 seconds
        gitlab Reconfigured!
        可以看到提示執(zhí)行了3分鐘29秒!
        查看啟動情況
        #netstat -tunlp
        Active Internet connections (only servers)
        Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
        tcp        0      0 127.0.0.1:9121              0.0.0.0:*                   LISTEN      7685/redis_exporter 
        tcp        0      0 127.0.0.1:9090              0.0.0.0:*                   LISTEN      7839/prometheus     
        tcp        0      0 127.0.0.1:9187              0.0.0.0:*                   LISTEN      7850/postgres_expor 
        tcp        0      0 127.0.0.1:9100              0.0.0.0:*                   LISTEN      7638/node_exporter  
        tcp        0      0 127.0.0.1:9168              0.0.0.0:*                   LISTEN      7865/ruby           
        tcp        0      0 127.0.0.1:8080              0.0.0.0:*                   LISTEN      7519/unicorn master 
        tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      7561/nginx          
        tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      5506/sshd           
        tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      5585/master         
        tcp        0      0 0.0.0.0:8060                0.0.0.0:*                   LISTEN      7561/nginx          
        tcp        0      0 :::3306                     :::*                        LISTEN      6289/MySQLd         
        tcp        0      0 ::1:9168                    :::*                        LISTEN      7865/ruby           
        tcp        0      0 :::22                       :::*                        LISTEN      5506/sshd           
        tcp        0      0 ::1:25                      :::*                        LISTEN      5585/master         
        關(guān)閉
        # sudo gitlab-ctl stop
        ok: down: gitaly: 0s, normally up
        ok: down: gitlab-monitor: 1s, normally up
        ok: down: gitlab-workhorse: 0s, normally up
        ok: down: logrotate: 0s, normally up
        ok: down: nginx: 0s, normally up
        ok: down: node-exporter: 0s, normally up
        ok: down: postgres-exporter: 1s, normally up
        ok: down: postgresql: 1s, normally up
        ok: down: prometheus: 0s, normally up
        ok: down: redis: 0s, normally up
        ok: down: redis-exporter: 0s, normally up
        ok: down: sidekiq: 0s, normally up
        ok: down: unicorn: 0s, normally up
        啟動
        # sudo gitlab-ctl start
        ok: run: gitaly: (pid 8296) 0s
        ok: run: gitlab-monitor: (pid 8301) 0s
        ok: run: gitlab-workhorse: (pid 8304) 1s
        ok: run: logrotate: (pid 8312) 0s
        ok: run: nginx: (pid 8318) 1s
        ok: run: node-exporter: (pid 8324) 0s
        ok: run: postgres-exporter: (pid 8329) 1s
        ok: run: postgresql: (pid 8334) 0s
        ok: run: prometheus: (pid 8342) 0s
        ok: run: redis: (pid 8350) 1s
        ok: run: redis-exporter: (pid 8354) 0s
        ok: run: sidekiq: (pid 8359) 1s
        ok: run: unicorn: (pid 8362) 0s
        重啟
        #sudo gitlab-ctl restart      #其實不加sudo也可以!
        查看添加了幾個用戶,如下:
        #tail -5 /etc/passwd
        gitlab-www:x:498:499::/var/opt/gitlab/nginx:/bin/false
        git:x:497:498::/var/opt/gitlab:/bin/sh
        gitlab-redis:x:496:497::/var/opt/gitlab/redis:/bin/false
        gitlab-psql:x:495:496::/var/opt/gitlab/postgresql:/bin/sh
        gitlab-prometheus:x:494:495::/var/opt/gitlab/prometheus:/bin/sh

        三、登錄驗證

        在瀏覽器輸入http://192.168.159.129  就可以看到GitLab的界面了,如下:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        第一次登錄需要設(shè)置新密碼,并且密碼長度不能小于8!設(shè)置好之后,會跳轉(zhuǎn)到登錄界面,如下:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        默認用戶名是root,然后輸入剛才新設(shè)置的密碼,登錄之后,界面如下:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        到這里一鍵安裝GitLab就完成了,就可以進行創(chuàng)建項目之類的操作了。

        四、postgresql相關(guān)命令介紹

        注:因為使用一鍵安裝GitLab的rpm包,默認數(shù)據(jù)庫是postgresql,所以對于不熟悉的朋友,可以參考!

        查看postgresql的數(shù)據(jù)存放目錄
        [root@web1 gitlab]# su - gitlab-psql
        -sh-4.1$ ll
        total 4
        drwx------ 19 gitlab-psql root 4096 May 25 10:55 data
        -sh-4.1$ ll data/
        total 112
        drwx------ 6 gitlab-psql root         4096 May 25 10:46 base
        drwx------ 2 gitlab-psql root         4096 May 25 10:55 global
        drwx------ 2 gitlab-psql root         4096 May 25 10:46 pg_clog
        drwx------ 2 gitlab-psql root         4096 May 25 10:46 pg_commit_ts
        drwx------ 2 gitlab-psql root         4096 May 25 10:46 pg_dynshmem
        -rw-r--r-- 1 gitlab-psql root         3198 May 25 10:46 pg_hba.conf
        -rw-r--r-- 1 gitlab-psql root         1789 May 25 10:46 pg_ident.conf
        drwx------ 4 gitlab-psql root         4096 May 25 10:46 pg_logical
        drwx------ 4 gitlab-psql root         4096 May 25 10:46 pg_multixact
        drwx------ 2 gitlab-psql root         4096 May 25 10:55 pg_notify
        drwx------ 2 gitlab-psql root         4096 May 25 10:46 pg_replslot
        drwx------ 2 gitlab-psql root         4096 May 25 10:46 pg_serial
        drwx------ 2 gitlab-psql root         4096 May 25 10:46 pg_snapshots
        drwx------ 2 gitlab-psql root         4096 May 25 10:55 pg_stat
        drwx------ 2 gitlab-psql root         4096 May 25 11:11 pg_stat_tmp
        drwx------ 2 gitlab-psql root         4096 May 25 10:46 pg_subtrans
        drwx------ 2 gitlab-psql root         4096 May 25 10:46 pg_tblspc
        drwx------ 2 gitlab-psql root         4096 May 25 10:46 pg_twophase
        -rw------- 1 gitlab-psql root            4 May 25 10:46 PG_VERSION
        drwx------ 3 gitlab-psql root         4096 May 25 11:10 pg_xlog
        -rw------- 1 gitlab-psql root           88 May 25 10:46 postgresql.auto.conf
        -rw-r--r-- 1 gitlab-psql root        20132 May 25 10:46 postgresql.conf
        -rw------- 1 gitlab-psql gitlab-psql    90 May 25 10:55 postmaster.opts
        -rw------- 1 gitlab-psql gitlab-psql   101 May 25 10:55 postmaster.pid
        postgresql 版本
        #cat PG_VERSION 
        9.6
        查看postgresql的進程
        #ps aux | grep postgre
        root       7378  0.0  0.0   3940   360 ?        Ss   10:46   0:00 runsv postgresql
        root       7379  0.0  0.0   4084   472 ?        S    10:46   0:00 svlogd -tt /var/log/gitlab/postgresql
        root       7697  0.0  0.0   3940   356 ?        Ss   10:48   0:00 runsv postgres-exporter
        root       7698  0.0  0.0   4084   476 ?        S    10:48   0:00 svlogd -tt /var/log/gitlab/postgres-exporter
        495       13278  0.0  0.6 127968 11924 ?        Ssl  11:41   0:03 /opt/gitlab/embedded/bin/postgres_exporter -web.listen-address=localhost:9187
        495       13283  0.0  1.7 545204 34160 ?        Ss   11:41   0:00 /opt/gitlab/embedded/bin/postgres -D /var/opt/gitlab/postgresql/data
        495       13287  0.0  1.0 545320 20344 ?        Ss   11:41   0:02 postgres: checkpointer process                                      
        495       13288  0.0  0.2 545204  5032 ?        Ss   11:41   0:00 postgres: writer process                                            
        495       13289  0.0  0.8 545204 16228 ?        Ss   11:41   0:00 postgres: wal writer process                                        
        495       13290  0.0  0.1 545776  2196 ?        Ss   11:41   0:00 postgres: autovacuum launcher process                               
        495       13291  0.0  0.0  31012  1460 ?        Ss   11:41   0:00 postgres: stats collector process                                   
        495       13332  0.0  0.4 644080  8408 ?        Ss   11:41   0:01 postgres: gitlab-psql postgres [local] idle                         
        495       14219  0.0  0.4 644128  8892 ?        Ss   11:50   0:00 postgres: gitlab gitlabhq_production [local] idle                   
        495       15207  0.0  0.4 643884  8160 ?        Ss   12:00   0:00 postgres: gitlab gitlabhq_production [local] idle                   
        495       15208  0.0  0.4 643888  8392 ?        Ss   12:00   0:00 postgres: gitlab gitlabhq_production [local] idle                   
        495       19681  0.0  0.3 643428  6804 ?        Ss   12:46   0:00 postgres: gitlab gitlabhq_production [local] idle                   
        495       19706  0.0  0.3 643428  6812 ?        Ss   12:47   0:00 postgres: gitlab gitlabhq_production [local] idle      
        
        可以看到啟動之后的postgresql有2個默認數(shù)據(jù)庫,一個是postgres,一個是gitlabhq_production!
        進入postgresql控制臺方法,在postgreSQL的安裝目的bin下執(zhí)行命令: 
        用法:psql database_name,
        例:/usr/local/pgsql/bin/psql mydb
        指定host、用戶名和數(shù)據(jù)庫的話,如:
        /usr/local/pgsql/bin/psql -h localhost -U postgres -d testdb
        注:-h 也可以指定socket文件目錄
        #########################################
        進入postgresql的gitlabhq_production庫
        #su - gitlab-psql
        -sh-4.1$ /opt/gitlab/embedded/bin/psql -h /var/opt/gitlab/postgresql -d gitlabhq_production
        psql (9.6.1)
        Type "help" for help.
        gitlabhq_production=# help
        You are using psql, the command-line interface to PostgreSQL.
        Type:  \copyright for distribution terms
               \h for help with SQL commands
               \? for help with psql commands
               \g or terminate with semicolon to execute query
               \q to quit
        gitlabhq_production=# \q      #退出
        注意:-h 后面指定服務(wù)器ip或者socket文件所在目錄
        進入postpgresql的postgres庫
        #su - gitlab-psql
        -sh-4.1$ psql -h /var/opt/gitlab/postgresql -d postgres
        psql (9.6.1)
        Type "help" for help.
        postgres=# 
        ##############################################
        postgresql的其他用法介紹
        創(chuàng)建數(shù)據(jù)庫
        CREATE DATABASE test WITH OWNER = postgres ENCODING = 'UTF8';
        查看版本: 
        #psql --version 或 SELECT version();
        查看所有數(shù)據(jù)庫:\l
        選擇數(shù)據(jù)庫:\c databasename
        查看所有表:\dt
        查看某個表的結(jié)構(gòu):\d tablename
        退出psql控制臺:\q
        查看所有索引:\di
        
        查看表的索引:
        select * from pg_indexes where tablename='log';
        查看數(shù)據(jù)庫大?。?select pg_size_pretty(pg_database_size('test_db'));
        查看所有數(shù)據(jù)庫大小
        select pg_database.datname, pg_database_size(pg_database.datname) AS size from pg_database;
        查看表的大?。?select pg_size_pretty(pg_relation_size('test_table'));
        查看表的總大小,包括索引大小  
        select pg_size_pretty(pg_total_relation_size('test')); 
        查看所有表空間  
        select spcname from pg_tablespace;          
        查看表空間大小
        select pg_size_pretty(pg_tablespace_size('pg_default'));
        
        導(dǎo)出備份數(shù)據(jù)庫:
        pg_dump -h localhost -U postgres databasename > /tmp/databasename.bak.yyyymmdd.sql
        導(dǎo)入恢復(fù)數(shù)據(jù)庫(sql文件是pg_dump導(dǎo)出的文件就行,可以是整個數(shù)據(jù)庫,也可以只是單個表,也可以只是結(jié)構(gòu)等):
        psql -h localhost -U postgres -d databasename < /tmp/databasename.bak.yyyymmdd.sql
        
        導(dǎo)出某個表:
        pg_dump -h localhost -U postgres -t tablename dbname > test.sql
        導(dǎo)出某個表的結(jié)構(gòu),加參數(shù)"-s":
        pg_dump -h localhost -U postgres -t tablename -s dbname > test_construct.sql
        導(dǎo)出某個表的數(shù)據(jù),加參數(shù)"-a":
        pg_dump -h localhost -U postgres -t tablename -a dbname > test_data.sql
        查看序列:
        select * from information_schema.sequences where sequence_schema = 'public';

        五、通過Git工具提交windows上的代碼到GitLab上

        說明:很多開發(fā)人員喜歡使用Git工具來提交代碼到GitLab,那么這里就著重介紹下。

        1、首先下載Git并安裝

        下載地址:https://git-for-windows.github.io  下載好之后雙擊Git-2.13.0-64-bit.exe安裝即可。

        注:一路Next,按照默認的選擇即可!(我是這么干的,如果你自己有特殊需要,可以自定義)

        2、打開Git并配置,如下圖:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        雙擊“Git Bash”會彈出一個shell 方框,如下:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        好了,Git Bash也打開了,下面我們在GitLab上注冊一個普通用戶,然后提交代碼。

        3、在GitLab上注冊用戶,如下圖:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        注冊成功之后,會看到一個提示注冊成功的頁面,提示:Welcome! You have signed up successfully.

        因為是內(nèi)部測試虛擬機,網(wǎng)絡(luò)比較慢,所以注冊普通賬號之后,發(fā)送郵件有些延遲,還發(fā)到了垃圾郵箱中,如下圖:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        可以看到郵件內(nèi)容是提示你添加pub key,按照下面的步驟添加即可!

        4、創(chuàng)建一個項目

        注冊好之后,點擊右上角的“+”圖標(biāo)(創(chuàng)建新項目圖標(biāo))開始創(chuàng)建新項目,如下圖:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        點擊“Create project”之后,會重新打開一個頁面,如下:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        可以根據(jù)提示得知,新用戶創(chuàng)建的項目需要將SSH key添加進來!點擊“add an SSH key”會出現(xiàn)一個新的頁面,提示你需要將生成的pub key粘貼在里面,如下圖:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        好的,執(zhí)行到這一步我們將視線轉(zhuǎn)移到windows機器的Git工具,通過這個工具生成公鑰,然后添加。

        5、使用Git生成公鑰并添加到GitLab

        生成公鑰命令:ssh-keygen -t rsa -C "郵箱"    然后一路回車即可!

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        根據(jù)上圖的提示,生成的公鑰在C:\Users\Administrator.2345-20170207QA\.ssh目錄下面,然后找到打開id_rsa.pub將其中的字符串原封不動的復(fù)制到GitLab頁面,如下圖:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        點擊“Add key”會彈出一個頁面,表示key添加成功,Title 會自動補全生成key時候輸入的郵箱地址!

        6、然后測試上傳代碼到GitLab的mytest項目

        其實上傳代碼的一些命令在GitLab界面的新項目頁面是給到我們的,我們按照上面的步驟操作即可,如下命令:

        Git global setup   全局設(shè)置
        
        $git config --global user.name "new_user_name"  #注冊時候的用戶名
        $git config --global user.email "生成pub key時候的郵箱地址"
        
        Create a new repository   創(chuàng)建一個新的庫
        
        $git clone [email protected]:new_user_name/mytest.git
        $cd mytest
        $touch README.md
        $git add README.md
        $git commit -m "add README"
        $git push -u origin master
        因為是新項目,沒有任何其他文件,所以執(zhí)行以上8條命令即可?。?!
        #####################################################################
        Existing folder          已經(jīng)存在的目錄
        cd existing_folder
        git init
        git remote add origin [email protected]:new_user_name/mytest.git
        git add .
        git commit
        git push -u origin master
        
        Existing Git repository  已經(jīng)存在的一個庫
        cd existing_repo
        git remote add origin [email protected]:new_user_name/mytest.git
        git push -u origin --all
        git push -u origin --tags

        在Git Bash工具中執(zhí)行上面列出的8條命令,如下圖:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        注:執(zhí)行第三條命令的時候,報錯了,提示不能解析gitlab.example.com 因為是內(nèi)部測試機我沒有做任何解析,所以報錯了。那么我就在本機windows機器的hosts文件中解析一下,然后重新執(zhí)行就ok了!

        192.168.159.129  gitlab.example.com

        執(zhí)行第三條命令的目的是將gitlab上面我們創(chuàng)建的項目mytest拉到本地,我們看看是否拉取成功,如下圖:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        可以看到mytest/ 已經(jīng)成功拉取到了windows機器上!

        繼續(xù)執(zhí)行命令,在mytest/項目下創(chuàng)建一個README.md文件,并上傳到gitlab上,如下圖:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        上傳成功之后,我們到gitlab上mytest項目中查看上傳的文件,如下圖:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        可以看到README.md文件已經(jīng)成功上傳到mytest/項目中了!

        ############################################

        上面介紹的是上傳本地代碼到gitlab上,對開發(fā)人員來說項目名和代碼都是英文的,便于維護。但對于系統(tǒng)工程師來說可能需要上傳一些文檔到gitlab上以便其他技術(shù)人員參考,所以下面我介紹一下上傳中文目錄和文件到gitlab的方法:首先在本機windows機器的項目目錄(這里以mytest項目為例)下面創(chuàng)建一個中文目錄,如下圖:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        然后在“測試中文目錄”下面創(chuàng)建一個“測試1.txt”文件,然后通過Git Bash工具上傳到git上,如下圖

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        執(zhí)行標(biāo)紅的2、3、4這3條命令即可!然后到gitlab上查看是否可以正常顯示中文,如下圖:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        可以看到中文在gitlab上顯示正常。剛才我只是在“測試中文目錄”中創(chuàng)建了“測試1.txt"文件,沒有在其中寫入中文,現(xiàn)在我寫入一行中文測試,內(nèi)容是“這是為了測試gitlab是否可以正常顯示中文!”然后再push到gitlab上,如下圖:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        執(zhí)行完成之后,到gitlab上查看,如下圖:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        可以看到也是正常的?。。?/p>

        注意:在gitlab上不能直接創(chuàng)建中文或者帶有中文的項目名,會報錯的提示如下:

        Path can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'

        你可以創(chuàng)建一個英文項目名,在此項目下創(chuàng)建中文目錄,保存中文文檔。不過據(jù)說可以使用工具來實現(xiàn)創(chuàng)建中文項目名的目的,這個就不介紹了。

        六、gitlab忘記密碼如何找回

        注:有些朋友密碼比較多容易記混或者忘記,那么如果忘記密碼,如何找回呢?

        首先你在gitlab的登錄界面點擊忘記密碼(Forgot your password)的連接,如下:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        然后會彈出一個頁面,如下:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        輸入注冊用戶時候留下的郵箱地址,這里就顯示出了郵箱地址的重要性,然后點擊“Reset password",在彈出的頁面上會提示你已經(jīng)發(fā)送了重置密碼的郵件到你的郵箱,然后你到自己郵箱查看,如下圖:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        可以在垃圾箱中看到郵件,查看郵件并點擊“Reset password”會彈出重置密碼頁面,你重新輸入自己的新密碼即可。然后彈出重新登錄界面,輸入用戶名和新設(shè)置的密碼,就可以順利登錄了!最后會發(fā)送一封郵件告知你密碼已經(jīng)成功修改,如下圖:

        GitLab的一鍵安裝方式以及使用Git工具上傳代碼

        不足之處,請多多留言指教!

        新聞名稱:GitLab的一鍵安裝方式以及使用Git工具上傳代碼
        網(wǎng)頁網(wǎng)址:http://www.jbt999.com/article26/ijjicg.html

        成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站ChatGPT、用戶體驗定制開發(fā)、Google、軟件開發(fā)

        廣告

        聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

        成都seo排名網(wǎng)站優(yōu)化

      2. 
        

          <address id="upfr9"><pre id="upfr9"><strike id="upfr9"></strike></pre></address>
          1. <address id="upfr9"><tr id="upfr9"></tr></address><dl id="upfr9"></dl>
            无码专区日韩 | 美女抽插网站 | 色接久久 | 色欲999 | 婷婷社区五月天 | 国产视频乱伦 | 影音先锋91麻豆 | 日韩在线观a片高清 | 大香蕉黄色网址 | 成人无码不卡免费视频 |