如何给 git repo 命名?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5055791/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 10:08:45  来源:igfitidea点击:

How to give a git repo a name?

git

提问by mko

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?

有没有人可以告诉我如何做到这一点?

回答by

It is possible to create a git repository directly in a folder, without the subdirectory .git. To do this, you do this:

可以直接在文件夹中创建 git 存储库,而无需子目录.git。为此,您可以这样做:

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 .gitfolder. It has no working copy. These sorts of repositories are usually used in the remote server (where you're pushing your changes); i.e., 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.)

这称为裸存储库 - 它包含通常位于.git文件夹中的内容。它没有工作副本。这些类型的存储库通常用于远程服务器(您正在推送更改的地方);即,当您的远程存储库基本上反映了您在本地提交的内容,并且没有人直接处理远程服务器位置的代码时(因此不需要工作副本。)

More detail:

更多详情:

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

回答by user611775

The nameis given by the directory, as mentioned above, though it does support given a descriptionfor software like gitweb:

名称由目录,给定,如上面提到的,虽然它不支持给予了说明像的GitWeb软件:

echo "Happy description" >.git/description

回答by Elbert Alias

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, e.g. "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