
# 克隆GitHub代码仓到本地
#### 克隆代码仓库到本地
1. 创建分支"develop"后，请单击左上角的代码仓名称"url-link-extractor"，进入该代码仓首页。
2. 单击"Code"，复制代码仓库的HTTPS地址。 
   图1复制HTTPS地址
   ![](https://support.huaweicloud.com/bestpractice-codeartsagent/zh-cn_image_0000002658454288.png "点击放大")
   
   
3. 打开本地Git Bash客户端，执行以下命令，克隆代码仓库到本地，**执行命令过程中，请在自动弹出的浏览器窗口及时完成认证** 。
   
   - 如果您处于外网，请执行如下命令：
     ```
     git clone -b develop https://github.com/GitHub用户名/仓库名.git
     ```
     
   
   - 如果您处于内网，请执行如下命令：
     ```
     git clone -b develop \ -c http.proxy="http://<proxy_user>:<proxy_password>@<proxy_host>:<proxy_port>" \ -c https.proxy="http://<proxy_user>:<proxy_password>@<proxy_host>:<proxy_port>" \ https://github.com/GitHub用户名/仓库名.git
     ```
     其中，*\<proxy_user\>:\<proxy_password\>* 为代理登录的账号和密码；*\<proxy_host\>* 为代理服务器域名，*\<proxy_port\>* 为代理服务监听端口，*https://github.com/GitHub用户名/仓库名.git*需要替换为代码仓库的HTTPS克隆地址。
     ![](https://support.huaweicloud.com/bestpractice-codeartsagent/public_sys-resources/caution_3.0-zh-cn.png)
     如果你的密码中包含@、%等特殊字符，请先进行**URL转义再填写**，否则会导致代理配置无效。
     例如，你的密码为Admin%@test，那么URL转义后的密码为Admin%25%40test。常用特殊字符的URL转义请参考[表1]。
      表1常用字符的URL转义表格 
     | 字符 | URL转义编码 |
     |:---|:---|
     | @  | %40     |
     | %  | %25     |
     | \& | %26     |
     | =  | %3D     |
     | +  | %2B     |
     | 空格 | %20     |
     | #  | %23     |
     | /  | %2F     |
        
     出现如下回显，表示代码仓成功克隆到本地。
     ```
     Cloning into 'url-link-extractor'...
     remote: Enumerating objects: 8, done.
     remote: Counting objects: 100% (8/8), done.
     remote: Compressing objects: 100% (5/5), done.
     remote: Total 8 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
     Receiving objects: 100% (8/8), done.
     ```
     
   
   
   
   
4. 克隆代码仓库"url-link-extractor"到本地后，请进入代码仓库"url-link-extractor"，在Git Bash客户端执行如下命令，拉取最新代码。 
   ```
   git pull origin develop
   ```
   出现如下回显，表示已拉取远端develop分支最新代码，本地代码和远端完全一致，没有需要更新的内容。如果出现冲突，请先解决代码冲突的问题。
   ```
   From https://github.com/username/url-link-extractor
    * branch            develop    -> FETCH_HEAD
   Already up to date.
   ```
   
   
 
