git remote 是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20889346/
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 17:31:13  来源:igfitidea点击:

What does git remote mean?

gitgit-remote

提问by Sandbox

What does remote mean? When cloning a repository located at a central location, aren't we creating its remote version?

远程是什么意思?克隆位于中心位置的存储库时,我们不是在创建其远程版本吗?

When I execute the command

当我执行命令时

$ git remote

I get origin. What does this mean?

我得到起源。这是什么意思?

When I execute

当我执行

$ git branch -r

I get origin/master. Now what is this?

我得到origin/master。现在这是什么?

回答by Popeye

I found a fantastic answer here:

我在这里找到了一个很棒的答案:

As you probably know, gitis a distributed version control system. Most operations are done locally. To communicate with the outside world, git uses what are called remotes. These are repositories other than the one on your local disk which you can push your changes into (so that other people can see them) or pull from (so that you can get others changes). The command git remote add origin [email protected]:peter/first_app.gitcreates a new remotecalled originlocated at [email protected]:peter/first_app.git. Once you do this, in your push commands, you can push to origininstead of typing out the whole URL.

您可能知道,git是一个分布式版本控制系统。大多数操作在本地完成。为了与外部世界通信,git 使用所谓的remotes。这些是本地磁盘以外的存储库,您可以将更改推送到其中(以便其他人可以看到它们)或从中拉出(以便您可以获取其他更改)。该命令git remote add origin [email protected]:peter/first_app.git创建一个名为origin的新遥控器,位于。执行此操作后,在您的推送命令中,您可以推送到原点而不是输入整个 URL。[email protected]:peter/first_app.git

I would recommend reading the whole answer.

我建议阅读整个答案。

回答by Emil Davtyan

A remotein git is basically a bookmarkfor a different repository from which you may wish to pull or push code.

remotegit 中的A基本上是不同存储库的书签,您可能希望从中拉取或推送代码。

The bookmarked repository may be on your local computer in a different folder, on remote server, or it may even be the repository itself ( I haven't tried this ) but the simplest analogy is a bookmark.

带书签的存储库可能位于您本地计算机上的不同文件夹、远程服务器上,或者甚至可能是存储库本身(我还没有尝试过),但最简单的类比是书签。

The repository doesn't even have to be a version of your repository, it may even be a completely unrelated repository.

存储库甚至不必是您的存储库的一个版本,它甚至可能是一个完全不相关的存储库。

回答by harshvchawla

Q) What does remote mean? When cloning a repository located at a central location, aren't we creating its remote version?
Ans)

问)远程是什么意思?克隆位于中心位置的存储库时,我们不是在创建其远程版本吗?
答)

Remote repositories are versions of your project that are hosted on the Internet or network somewhere.

远程存储库是托管在 Internet 或网络某处的项目版本。

So, your point of reference is the machine on which you are running your commands (your laptop) and ergo the central location where repo is hosted for collaborators is the "remote"

因此,您的参考点是您运行命令的机器(您的笔记本电脑),因此为合作者托管 repo 的中心位置是“远程”

Q) When I execute the command

Q) 当我执行命令时

$ git remote
$ git remote

I get origin. What does this mean?
Ans)

我得到起源。这是什么意思?
答)

(git remote command) lists the shortnames of each remote handle you've specified. If you've cloned your repository, you should at least see origin – that is the default name Git gives to the server you cloned from.

(git remote command) 列出您指定的每个远程句柄的短名称。如果你已经克隆了你的仓库,你至少应该看到 origin——这是 Git 为你克隆的服务器提供的默认名称。

Specifying git remote -v will give you the shortname and corresponding url of the "remote" (aka the repo)

指定 git remote -v 将为您提供“remote”(又名 repo)的短名称和相应的 url

Q) When I execute

问)当我执行

$ git branch -r
$ git branch -r

I get origin/master. Now what is this?
Ans) origin being the shortname created by git for you to refer to your remote repo; master being the default branch pointing to the last commit Therefore, "git branch -r" will list the remote(origin) branch(master)

我得到起源/主人。现在这是什么?
Ans) origin 是由 git 创建的短名称,供您参考远程仓库;master 是指向最后一次提交的默认分支因此,“git branch -r”将列出远程(源)分支(master)

References:

参考:

  1. https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes
  2. https://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell#_git_branching
  1. https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes
  2. https://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell#_git_branching