简体   繁体   English

如何给 git repo 命名?

[英]How to give a git repo a name?

I am making a remote repo by using these command我正在使用这些命令制作远程仓库

mkdir NewRepo
cd NewRepo
git init

Then I clone this repo to local然后我将这个 repo 克隆到本地

git clone user@server:/path/to/app/.git

This worked for me, But I want give the repo a name, do something like everybody else does:这对我有用,但我想给 repo 一个名字,像其他人一样做一些事情:

git clone user@server:/path/to/app/reponame.git

Is there anyone who can tell me how to do this?有没有人可以告诉我如何做到这一点?

It is possible to create a git repository directly in a folder, without the subdirectory .git .可以直接在文件夹中创建 git 存储库,而无需子目录.git To do this, you do this:为此,您可以这样做:

mkdir myrepo.git
cd myrepo.git
git init --bare

This is called a bare repository - it contains the contents of what would normally be in a .git folder.这称为裸存储库 - 它包含通常位于.git文件夹中的内容。 It has no working copy.它没有工作副本。 These sorts of repositories are usually used in the remote server (where you're pushing your changes);这些类型的存储库通常用于远程服务器(您正在推送更改的地方); ie, when your remote repository basically reflects what you've committed locally, and nobody is working directly on the code in the remote server location (therefore no need for a working copy.)即,当您的远程存储库基本上反映了您在本地提交的内容,并且没有人直接处理远程服务器位置的代码时(因此不需要工作副本。)

More detail:更多详情:

  1. Use in distributed workflows . 在分布式工作流中使用
  2. setting up a public repository 设置公共存储库

名称由目录给出,如上所述,尽管它确实支持对 gitweb 等软件的描述

echo "Happy description" >.git/description

Repositories don't have names, you just use the folder name (I suppose you could name the folder "app.git":存储库没有名称,您只需使用文件夹名称(我想您可以将文件夹命名为“app.git”:

git clone user@server:/path/to/app

Remotes do have names, eg "origin" or whatever you like.遥控器确实有名称,例如“起源”或您喜欢的任何名称。 This is up to the client though, not a property of the remote repository.不过,这取决于客户端,而不是远程存储库的属性。

git remote add origin user@server:/path/to/app

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM