当前位置:   article > 正文

git ------ git clone方法总结(可直接加账户和密码)_git clone -o

git clone -o

 设置账号和密码,解决仓库路径一样,但登陆者不同。不必全局改动账号!!!!

git clone命令格式:

git clone [--template=<template_directory>]
    [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
    [-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]
    [--dissociate] [--separate-git-dir <git dir>]
    [--depth <depth>] [--[no-]single-branch]
    [--recursive | --recurse-submodules] [--[no-]shallow-submodules]
    [--jobs <n>] [--] <repository> [<directory>]

其中,常用的参数如下:

-n, 不检出Git库中的active branch
-o new_origin, 使用new_origin,而不使用默认的origin,作为跟踪分支的upstream所在库
-b new_branch, 设置本地的active branch,而非默认的master branch
--single-branch, 只检查一个branch,要么是默认的master,要么是-b new_branch指定的new_branch
--recursive, 在本地初始化Git库中的所有模块
 

1.git clone 不指定分支(默认master分支)

 git clone  远程仓库git地址  <本地仓库名> // <>自定义本地仓库名,不写默认远程分支名

2.git clone 指定分支(非主分支)

 git clone -b 远程指定分支 远程仓库git地址 <本地仓库名> // <>自定义本地仓库名,不写默认远程分支名

3.不设全局账号密码,拉取远程指定仓库的代码:

  1. git clone http://username:password@remote
  2. 例子:
  3. 地址为:(http://)(git.xxx.com/www.git) ()是书写时要分开的:
  4. git clone http://username:password@git.xxx.com/www.git

4.拷贝一个 Git 仓库到本地,重新定义本地目录名称

  1.  git clone <版本库的网址> <本地目录名>
  2. example:
  3. git clone http://git@cocoli.git my-master //远程默认为master ,本地设置为了my-master

5.拷贝一个git仓库,修改远程仓库名:

  1. git clone -o new_remote_name <url> <new_branch>
  2. “origin” 并无特殊含义
  3. 远程仓库名字 “origin” 与分支名字 “master” 一样,在 Git 中并没有任何特别的含义一样。
  4. 同时 “master” 是当你运行 git init 时默认的起始分支名字,原因仅仅是它的广泛使用,
  5. “origin” 是当你运行 git clone 时默认的远程仓库名字。 如果你运行 git clone -o
  6. booyah,那么你默认的远程分支名字将会是 booyah/master。

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/573761
推荐阅读
相关标签
  

闽ICP备14008679号