国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
Use git init and git clone to obtain the git warehouse
1 git init creates a Git repository in the local directory
Home Development Tools git Detailed examples of git init and git clone to obtain git warehouse

Detailed examples of git init and git clone to obtain git warehouse

Apr 02, 2022 pm 01:18 PM
git

This article brings you relevant knowledge about Git, which mainly introduces the related issues of git init and git clone to obtain the git warehouse, including git clone from the existing Git storage database Clone the warehouse to a local directory and other related content, I hope it will be helpful to everyone.

Detailed examples of git init and git clone to obtain git warehouse

Recommended study: "Git Tutorial"

Use git init and git clone to obtain the git warehouse

Usually There are two ways to obtain a git repository:

  • Convert a local directory that is not under version control to a Git repository;

  • From other servers Clone an existing Git repository;

1 git init creates a Git repository in the local directory

git?init?[-q?|?--quiet]?[--bare]?[--template=<template_directory>]
???????????[--separate-git-dir?<git dir>]
???????????[--shared[=<permissions>]]?[directory]

This command creates an empty Git To store the database, objects, refs/heads, refs/tags, and template files will basically be created in the .git directory. An initial HEAD file is also created that references the HEAD of the master branch.
If the $GIT_DIR environment variable is specified, it will replace the ./.git directory as the basis for a repository.
If the objects directory is specified through the $GIT_OBJECT_DIRECTORY environment variable, then the sha1 directory is created in this directory, otherwise it is the default $GIT_DIR/objects Table of contents.
It is safe to run git init in an existing Git repository, it will not overwrite existing things. The main reason to rerun git init is to get the newly added templates (or to move the Git repository to another place in the case of the --separate-git-dir option).

  • [-q, --quite]
    Only print error messages and warning messages;
  • [--bare]
    Create a bare warehouse, excluding the .git folder, as follows:
    git init --bare
  • ##[--template=<template_directory>] is used to copy the files in the template folder to the
    .git storage database when we initialize the Git warehouse. If not specified, the default copy is /usr Templates under the path /share/git-core/templates, which include the following content: <pre class="brush:php;toolbar:false">$?ls?/usr/share/git-core/templates/ branches??description??hooks??info</pre> If you specify your own default path, the initialized Git storage database is as follows: git init --template The templates can be passed in turn through
    - -template= settings, $GIT_TEMPLATE_DIR environment variable settings, init.templateDir configuration settings, and override the lower-level settings in turn.
  • [--separate-git-dir <git dir>] By default
    git init will create a .git in the current directory folder to store the Git database. This command can specify a path to initialize the Git storage database and create a .git file locally to link to the specified directory:
    git init --separate You can see that there is only one
    .git file locally. The file describes the specific location of the Git storage database of the current warehouse and is automatically linked to it.
  • [--shared[=]] Used to specify the read and write permissions of the created Git storage database, including permissions for users in the same group, all users, etc. Setting, if not specified, defaults to
    group permissions. If you are interested, you can git init --help to view the specific usage of this option.
  • [directory] If this option is specified, the
    git init command will be run in this directory, and the directory will be created if it does not exist. .

2 git clone Clone the warehouse from the existing Git storage database to the local directory
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]?[--no-tags]
??????????[--recurse-submodules[=<pathspec>]]?[--[no-]shallow-submodules]
??????????[--[no-]remote-submodules]?[--jobs?<n>]?[--sparse]?[--]?<repository>
??????????[<directory>]

Clone a warehouse to the newly created directory, for Each branch in the cloned Git repository creates a remote tracking branch (the tracking branch can be viewed through

git branch --remotes), and creates and checks out the currently active branch of the cloned repository to the local initial branch. After cloning is completed, a
git fetch command without parameters can update all remote tracking branches, and a git pull command without parameters will also merge the remote master branch into in the current branch. This default configuration is created by creating a reference to the remote branch head under
refs/remotes/origin and initializing remote.origin.url and remote.origin.fetch Implemented by configuration variables.

  • [--template=<template_directory>]
    請(qǐng)看git init相關(guān)選項(xiàng)獲取此選項(xiàng)作用。
  • [-l, --local]
    用于從本地Git存儲(chǔ)倉(cāng)庫(kù)克隆Git存儲(chǔ)數(shù)據(jù)庫(kù),此選項(xiàng)會(huì)拷貝本地的refs,HEAD等信息到克隆的Git存儲(chǔ)數(shù)據(jù)庫(kù),并將.git/objects通過(guò)硬鏈接形式鏈接到本地Git存儲(chǔ)庫(kù)以節(jié)約本地空間。
    如果未指定-l選項(xiàng)但[url]是本地路徑則還是會(huì)默認(rèn)進(jìn)行-l選項(xiàng)的行為,但是如果指定的是--no-local選項(xiàng)對(duì)本地倉(cāng)庫(kù)進(jìn)行克隆則會(huì)走默認(rèn)的git clone流程:
    git clone --no-local
  • [-s, --shared]
    當(dāng)克隆的倉(cāng)庫(kù)在本地時(shí),默認(rèn)是將本地倉(cāng)庫(kù)中.git/objects的對(duì)象通過(guò)硬鏈接的方式鏈接到本地的克隆倉(cāng)庫(kù),使用此選項(xiàng)不會(huì)再硬鏈接.git/objects目錄,而是在本地的.git/objects/info目錄中創(chuàng)建一個(gè)alternates文件并在其中描述objects原先的位置并進(jìn)行共享使用。
    注意:這個(gè)選項(xiàng)是一個(gè)危險(xiǎn)的選項(xiàng),除非你明白它的作用,否則不要使用它。如果使用這個(gè)選項(xiàng)克隆了本地倉(cāng)庫(kù),然后刪除了源倉(cāng)庫(kù)中的分支,一些對(duì)象可能會(huì)變成未被引用狀態(tài)。而這些對(duì)象是可能被git的命令(git commit內(nèi)部可能自動(dòng)調(diào)用git gc --atuo)刪除的,從而導(dǎo)致倉(cāng)庫(kù)被破壞。
    還需要注意:在用-s選項(xiàng)克隆的存儲(chǔ)庫(kù)中運(yùn)行git repack時(shí),如果沒(méi)有指定--local,-l選項(xiàng),則會(huì)將源存儲(chǔ)庫(kù)中的objects復(fù)制到克隆存儲(chǔ)庫(kù)中的一個(gè)包里面,從而消除了--shared選項(xiàng)帶來(lái)的共享效果和節(jié)省的空間。直接運(yùn)行git gc是安全的,因?yàn)槟J(rèn)使用的--local,-l選項(xiàng)。
    如果想在-s選項(xiàng)指定的倉(cāng)庫(kù)中打破對(duì)共享的依賴,則可以使用git repack -a命令將源存儲(chǔ)庫(kù)中的所有對(duì)象復(fù)制到克隆的存儲(chǔ)庫(kù)的一個(gè)包中。
  • [--no-hardlinks]
    強(qiáng)制在克隆本地倉(cāng)庫(kù)時(shí)使用拷貝的形式復(fù)制.git/objects中的內(nèi)容而不是使用硬鏈接的形式,在進(jìn)行Git存儲(chǔ)庫(kù)備份時(shí)這個(gè)選項(xiàng)就很有用。
  • [-q, --quite]
    安靜的運(yùn)行命令,進(jìn)度不會(huì)報(bào)告到標(biāo)準(zhǔn)錯(cuò)誤流中。
  • [-n, --no-checkout]
    克隆完成后不執(zhí)行檢出HEAD操作:
    git clone -n
  • [--bare]
    創(chuàng)建一個(gè)裸的Git倉(cāng)庫(kù)。也就是說(shuō)不創(chuàng)建<directory>/.git目錄也不會(huì)將管理文件放到<directory>/.git中,而是為自己創(chuàng)建一個(gè)<directory>或者<directory>.git目錄,里面保存的就是實(shí)際的Git數(shù)據(jù)庫(kù)。這個(gè)選項(xiàng)也默認(rèn)是--no-checkout的,不會(huì)檢出任何HEAD,也不會(huì)自動(dòng)跟蹤任何遠(yuǎn)程分支,也不會(huì)創(chuàng)建相關(guān)的配置變量。
  • [--mirror]
    設(shè)置源Git存儲(chǔ)庫(kù)的鏡像。類似于--bare,對(duì)比--bare,--mirror不僅僅映射源的本地分支到目標(biāo)的本地分支,它還映射所有引用(包括遠(yuǎn)程跟蹤分支,筆記等),并設(shè)置refspec配置,以便所有這些引用都被目標(biāo)存儲(chǔ)庫(kù)中的git遠(yuǎn)程更新覆蓋。
    注意:--bare--mirror都是針對(duì)服務(wù)器使用,因?yàn)榉?wù)器只需要保存Git存儲(chǔ)數(shù)據(jù)庫(kù)而不需要實(shí)際操作git命令,所以當(dāng)你在這兩個(gè)選項(xiàng)創(chuàng)建的存儲(chǔ)庫(kù)執(zhí)行Git命令會(huì)得到下面的打?。?pre class="brush:php;toolbar:false">fatal:?this?operation?must?be?run?in?a?work?tree
  • [-o <name>, --origin <name>]
    未使用此選項(xiàng)時(shí)默認(rèn)使用origin來(lái)跟蹤遠(yuǎn)程倉(cāng)庫(kù),使用此選項(xiàng)后使用<name>來(lái)跟蹤遠(yuǎn)程倉(cāng)庫(kù)。
  • [-b <name>, --branch <name>]
    不要將新創(chuàng)建的HEAD指向克隆倉(cāng)庫(kù)HEAD指向的分支,而是指向<name>分支。
  • [-u <upload-pack>, --upload-pack <upload-pack>]
    在使用ssh訪問(wèn)要克隆的Git存儲(chǔ)庫(kù)時(shí),它為另一端運(yùn)行的命令指定了一個(gè)非默認(rèn)的路徑。這個(gè)選項(xiàng)主要針對(duì)Git服務(wù)器使用,為服務(wù)器使用的git等指定了一個(gè)路徑。一般是/usr/bin/git-upload-pack,當(dāng)服務(wù)器的git運(yùn)行時(shí)會(huì)自動(dòng)找到此路徑的程序。
  • [--reference[-if-able] <repository>]
    If the referenced Git repository is on the local machine, the .git/objects/info/alternates file will automatically be set up to fetch objects from the referencing source repository, using the existing Git repositories instead will require fewer objects to be copied from the source repository, thus reducing network and local storage costs. When --reference-if-able is used, non-existing directories are skipped and a warning is issued instead of aborting cloning.
  • [--dissociate]
    Borrowing objects objects from a Git repository referenced by --reference only reduces network transmission, and Stop borrowing objects from the reference library after cloning by making the necessary local copies of the borrowed objects. When a local clone is already borrowing objects from another repository, this option can be used to stop the new repository from borrowing objects from the same repository. This option is also mainly used for Git servers.
  • [--separate-git-dir <git dir>]
    Please see git init related options to get the effect of this option.
  • [--depth <depth>]
    Create a shallow clone with the number of commits that need to be cloned specified by <depth>, and get The top commits of all branches will be cloned locally with the number of <depth> commits. If you also want to simply clone submodules, you can also pass the --shallow-submodules option.
  • [--[no-]single-branch]
    As the name suggests, --single-branch will only clone a specified branch in the Git repository , other branches in the remote Git repository will not be cloned locally, nor will other remote branches be tracked locally, only a single remote branch will be tracked.
  • [--no-tags]
    Will not clone any tags and set remote.<remote>.tarOpt=--no- in the configuration tags to ensure that subsequent git pull and git fetch will not operate on the tag unless the tag is explicitly manipulated.
    Can be used with --single-branch to maintain a single branch, which is useful when only maintaining a certain default branch.
  • [--recurse-submodules[=<pathspec>]]
    After the clone is created, initialize and clone the submodules according to the provided <pathspec> module, if <pathspec> is not specified then all submodules are initialized and cloned. This option may be given multiple times for <parhspec> with multiple entries.
    Using this option by default is equivalent to running git submodule update --init --recursive <pathspec>.
  • [--[no-]shallow-submodules]
    All cloned submodules have a shallow clone depth of 1.
  • [--[no-]remote-submodules]
    Update the status of the remote tracking branch of all cloned submodules to update the submodule instead of recording it in the Git database SHA1. Equivalent to passing the --remote option to git submodule update.
  • [-j <n>, --jobs <n>]
    The number of submodules fetched at the same time, the default is configurationsubmodule.fetchJobs .
  • [--sparse]
    Sparse checkout mode, the so-called sparse checkout means that when checking out the local repository, it does not check out all, but only removes the specified files from the local repository. Checked out to the workspace, other unspecified files are not checked out (even if these files exist in the workspace, their modifications will be ignored). This feature is not described in detail here.
  • [--]
    Has no practical effect, just to separate options and operation objects for easy differentiation.
  • <repository>
    The warehouse to be cloned may be a remote warehouse or a local warehouse, and it may be https protocol or ssh protocol or git protocol, etc.
  • [<directory>]
    If this directory is specified, the Git repository will be cloned into this directory.
  • -v, --verbose
    Verbose output of clone information.
  • [-c <key>=<value>, --config <key>=<value]
    Store the newly created Git when cloning the repository The library sets a configuration variable, which takes effect immediately after the cloning is completed

Recommended learning: "Git Tutorial"

The above is the detailed content of Detailed examples of git init and git clone to obtain git warehouse. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1502
276
How do I view the commit history of my Git repository? How do I view the commit history of my Git repository? Jul 13, 2025 am 12:07 AM

To view Git commit history, use the gitlog command. 1. The basic usage is gitlog, which can display the submission hash, author, date and submission information; 2. Use gitlog--oneline to obtain a concise view; 3. Filter by author or submission information through --author and --grep; 4. Add -p to view code changes, --stat to view change statistics; 5. Use --graph and --all to view branch history, or use visualization tools such as GitKraken and VSCode.

How do I delete a Git branch? How do I delete a Git branch? Jul 13, 2025 am 12:02 AM

To delete a Git branch, first make sure it has been merged or no retention is required. Use gitbranch-d to delete the local merged branch. If you need to force delete unmerged branches, use the -D parameter. Remote branch deletion uses the gitpushorigin-deletebranch-name command, and can synchronize other people's local repositories through gitfetch-prune. 1. To delete the local branch, you need to confirm whether it has been merged; 2. To delete the remote branch, you need to use the --delete parameter; 3. After deletion, you should verify whether the branch is successfully removed; 4. Communicate with the team to avoid accidentally deleting shared branches; 5. Clean useless branches regularly to keep the warehouse clean.

Can I buy Dogecoin in the currency circle? How to identify scam items? Can I buy Dogecoin in the currency circle? How to identify scam items? Jul 10, 2025 pm 09:54 PM

The "Dogcoin" in the currency circle usually refers to newly issued cryptocurrencies with extremely low market value, opaque project information, weak technical foundation or even no practical application scenarios. These tokens often appear with high-risk narratives.

How do I add a subtree to my Git repository? How do I add a subtree to my Git repository? Jul 16, 2025 am 01:48 AM

To add a subtree to a Git repository, first add the remote repository and get its history, then merge it into a subdirectory using the gitmerge and gitread-tree commands. The steps are as follows: 1. Use the gitremoteadd-f command to add a remote repository; 2. Run gitmerge-srecursive-no-commit to get branch content; 3. Use gitread-tree--prefix= to specify the directory to merge the project as a subtree; 4. Submit changes to complete the addition; 5. When updating, gitfetch first and repeat the merging and steps to submit the update. This method keeps the external project history complete and easy to maintain.

How to identify fake altcoins? Teach you to avoid cryptocurrency fraud How to identify fake altcoins? Teach you to avoid cryptocurrency fraud Jul 15, 2025 pm 10:36 PM

To identify fake altcoins, you need to start from six aspects. 1. Check and verify the background of the materials and project, including white papers, official websites, code open source addresses and team transparency; 2. Observe the online platform and give priority to mainstream exchanges; 3. Beware of high returns and people-pulling modes to avoid fund traps; 4. Analyze the contract code and token mechanism to check whether there are malicious functions; 5. Review community and media operations to identify false popularity; 6. Follow practical anti-fraud suggestions, such as not believing in recommendations or using professional wallets. The above steps can effectively avoid scams and protect asset security.

What is the code number of Bitcoin? What style of code is Bitcoin? What is the code number of Bitcoin? What style of code is Bitcoin? Jul 22, 2025 pm 09:51 PM

As a pioneer in the digital world, Bitcoin’s unique code name and underlying technology have always been the focus of people’s attention. Its standard code is BTC, also known as XBT on certain platforms that meet international standards. From a technical point of view, Bitcoin is not a single code style, but a huge and sophisticated open source software project. Its core code is mainly written in C and incorporates cryptography, distributed systems and economics principles, so that anyone can view, review and contribute its code.

What is Useless Coin? Overview of USELESS currency usage, outstanding features and future growth potential What is Useless Coin? Overview of USELESS currency usage, outstanding features and future growth potential Jul 24, 2025 pm 11:54 PM

What are the key points of the catalog? UselessCoin: Overview and Key Features of USELESS The main features of USELESS UselessCoin (USELESS) Future price outlook: What impacts the price of UselessCoin in 2025 and beyond? Future Price Outlook Core Functions and Importances of UselessCoin (USELESS) How UselessCoin (USELESS) Works and What Its Benefits How UselessCoin Works Major Advantages About USELESSCoin's Companies Partnerships How they work together

How to set environment variables in PHP environment Description of adding PHP running environment variables How to set environment variables in PHP environment Description of adding PHP running environment variables Jul 25, 2025 pm 08:33 PM

There are three main ways to set environment variables in PHP: 1. Global configuration through php.ini; 2. Passed through a web server (such as SetEnv of Apache or fastcgi_param of Nginx); 3. Use putenv() function in PHP scripts. Among them, php.ini is suitable for global and infrequently changing configurations, web server configuration is suitable for scenarios that need to be isolated, and putenv() is suitable for temporary variables. Persistence policies include configuration files (such as php.ini or web server configuration), .env files are loaded with dotenv library, and dynamic injection of variables in CI/CD processes. Security management sensitive information should be avoided hard-coded, and it is recommended to use.en

See all articles