Git 克隆远程仓库到本地

Git 克隆远程仓库到本地

参考

$ git clone --help
https://git-scm.com/book/zh/v2/Git-%E5%9F%BA%E7%A1%80-%E8%8E%B7%E5%8F%96-Git-%E4%BB%93%E5%BA%93

当前目录 /e/mozq/02 project 。不指定则克隆 ${name}.git 到当前目录下${name}目录。如果指定路径,可以是相对路径和绝对路径,相对路径可以使用双点符表示上级目录。项目将被克隆到路径最后一个目录下。路径上所有不存在的目录将被创建。

不指定

# 不指定,克隆${name}.git到当前目录下的${name}目录。
1@DESKTOP-3H9092J MINGW64 /e/mozq/02 project
$ git clone https://github.com/shuzheng/zheng.git

Cloning into 'zheng'...
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 18806 (delta 2), reused 2 (delta 0), pack-reused 18798
Receiving objects: 100% (18806/18806), 40.27 MiB | 5.43 MiB/s, done.
Resolving deltas: 100% (7583/7583), done.
Checking out files: 100% (1251/1251), done.

相对路径

# 指定相对路径,克隆到路径最后一个目录。
1@DESKTOP-3H9092J MINGW64 /e/mozq/02 project
$ git clone https://github.com/shuzheng/zheng.git zhengcheng

Cloning into 'zhengcheng'...
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 18806 (delta 2), reused 2 (delta 0), pack-reused 18798
Receiving objects: 100% (18806/18806), 40.27 MiB | 7.29 MiB/s, done.
Resolving deltas: 100% (7583/7583), done.
Checking out files: 100% (1251/1251), done.

相对路径可以使用双点符

# 相对路径可以使用双点符表示上级目录。
1@DESKTOP-3H9092J MINGW64 /e/mozq/02 project
$ git clone https://github.com/shuzheng/zheng.git ../zhengcheng

Cloning into '../zhengcheng'...
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 18806 (delta 2), reused 2 (delta 0), pack-reused 18798
Receiving objects: 100% (18806/18806), 40.27 MiB | 3.31 MiB/s, done.
Resolving deltas: 100% (7583/7583), done.
Checking out files: 100% (1251/1251), done.

绝对路径

# 可以使用绝对路径。克隆到路径最后一个目录。
1@DESKTOP-3H9092J MINGW64 /e/mozq/02 project
$ git clone https://github.com/shuzheng/zheng.git e:/mozq/changzhou

Cloning into 'e:/mozq/changzhou'...
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 18806 (delta 2), reused 2 (delta 0), pack-reused 18798
Receiving objects: 100% (18806/18806), 40.27 MiB | 5.00 MiB/s, done.
Resolving deltas: 100% (7583/7583), done.
Checking out files: 100% (1251/1251), done.

路径中所有没有的文件夹将被创建

# 路径中所有没有的文件夹将被创建。
1@DESKTOP-3H9092J MINGW64 /e/mozq/02 project
$ git clone https://github.com/shuzheng/zheng.git e:/x1/x1/changzhou

Cloning into 'e:/x1/x1/changzhou'...
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 18806 (delta 2), reused 2 (delta 0), pack-reused 18798
Receiving objects: 100% (18806/18806), 40.27 MiB | 5.65 MiB/s, done.
Resolving deltas: 100% (7583/7583), done.
Checking out files: 100% (1251/1251), done.

git 克隆远程仓库之后

参考

https://git-scm.com/book/zh/v2/Git-%E5%9F%BA%E7%A1%80-%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93%E7%9A%84%E4%BD%BF%E7%94%A8
1@DESKTOP-3H9092J MINGW64 /e/00/project_01
$ git clone https://github.com/shuzheng/zheng.git
Cloning into 'zheng'...
remote: Enumerating objects: 18806, done.
remote: Total 18806 (delta 0), reused 0 (delta 0), pack-reused 18806
Receiving objects: 100% (18806/18806), 40.27 MiB | 4.08 MiB/s, done.
Resolving deltas: 100% (7585/7585), done.
Checking out files: 100% (1251/1251), done.

1@DESKTOP-3H9092J MINGW64 /e/00/project_01/zheng (master)
$ git branch
* master

1@DESKTOP-3H9092J MINGW64 /e/00/project_01/zheng (master)
$ git branch -v
* master 7005c0a7 升级commons-fileupload

1@DESKTOP-3H9092J MINGW64 /e/00/project_01/zheng (master)
$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/feature/springboot
  remotes/origin/master
  remotes/origin/springboot+dubbo
  
1@DESKTOP-3H9092J MINGW64 /e/00/project_01/zheng (master)
$ git remote -v
origin  https://github.com/shuzheng/zheng.git (fetch)
origin  https://github.com/shuzheng/zheng.git (push)

## bugs

windows中注意斜杠为右倒。而不是左倒。

1@DESKTOP-3H9092J MINGW64 /e/mozq/02 project
$ git clone https://github.com/shuzheng/zheng.git e:mozqchangzhou
Cloning into 'e:mozqchangzhou'...
fatal: Invalid path 'e:/mozqchangzhou': No such file or directory

原文地址:https://www.cnblogs.com/mozq/p/11717679.html