将 git 分支连接到 GitHub fork

发布于 2024-09-09 22:56:16 字数 221 浏览 4 评论 0原文

我通过终端访问 git,而不是 GitHub,我想知道如何在两者之间建立联系。

从我的结帐中,我通过运行以下命令在终端中创建了一个分支: git checkout -b newbranchname

据我了解,GitHub 称之为“分叉”。如何将我的盒子上的分支连接到 GitHub 上的结账分支?

(提前感谢您的帮助。我的背景是大约1.5年的颠覆。)

I came to git via terminal, not GitHub and I am wondering how I make a connection between the two.

From a checkout I have, I created a branch in terminal by running this command:
git checkout -b newbranchname

From my understanding, GitHub calls this "forking". How do I connect the branch on my box to a fork of a checkout on GitHub?

(Thanks ahead of time for your help. My background is about 1.5 years of subversion.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

霞映澄塘 2024-09-16 22:56:16

你把一些事情搞混了。

首先,SVN 中的结帐与 git 中的结帐不同。 SVN 中所谓的签出,git 中称为克隆。您无需签出存储库,而是克隆它。 “签出”意味着切换到特定分支,这与 svn switch 或多或少相同,但您还可以在同一步骤中创建新分支(这就是 -b 确实如此)。

所以我假设您一直在本地使用 git,现在已经在 github 上创建了一个项目,并且希望将您的更改推送到 github 存储库。

Fork 是 github 上现有第三方存储库的副本。您可以点击“fork”按钮来获取该存储库的您自己的副本,从而允许您进行自己的更改。然后,其他人可以将您所做的任何更改拉入他自己的存储库中。

要将 github 存储库与本地存储库关联起来(本地):

git remote add origin [email protected]:<username>/<repo>.git

推送更改:

git push origin master

您可以在此处找到一些很棒的 git 文档: http://git-scm.com/documentation

You're mixing a few things up.

First of all, a checkout in SVN is not the same as a checkout in git. What is called a checkout in SVN is called a clone in git. You don't check out a repository, you clone it. "Checking out" means switching to a specific branch, which is more or less the same as svn switch, but you also have the ability of creating a new branch in the same step (that's what -b does).

So I'm assuming that you have been using git locally, have now created a project on github and would like to push your changes to the github repo.

A fork is a copy of an existing third party repo on github. You can hit the "fork" button to get your own copy of that repository, allowing you to make your own changes. The other person can then pull in any changes you make into his own repository.

To associate your github repo with your local repo you do (locally):

git remote add origin [email protected]:<username>/<repo>.git

To push your changes:

git push origin master

You can find some great documentation for git here: http://git-scm.com/documentation

蓝色星空 2024-09-16 22:56:16

a/ 不,这不是分叉。
您已在本地存储库中创建了一个分支。
您可以将其推送到 GitHub 存储库,它将作为分支存在。

GitHub 手册页

要将本地分支推送到已建立的远程分支,您只需使用

git push REMOTENAME BRANCHNAME 

如果您不想在远程分支上使用相同的名称,可以使用

git push REMOTENAME LOCALBRANCHNAME:REMOTEBRANCHNAME.

b/ a fork 是 GitHub 端的存储库克隆(您可以依次在桌面本地端克隆它)

c/ 如果您想比较 GitHub 端不同分支之间的分支(因为,同样,分支只存在在 GitHub 这边;在你这边,你只是克隆远程仓库),你可以!
(嗯...从 2 天前,2010 年 7 月 15 日起就可以):
跨存储库比较视图:跨存储库比较分支的能力。


请记住,使用 DVCS,您有一个分支的额外维度:发布(push/从远程存储库拉取/拉取到远程存储库)

创建分支并不意味着 GitHub 上的所有其他分支都可以看到它。
它只是在您自己的存储库上本地创建的。出版部分留给你。

a/ no, that is not forking.
You have created a branch in your local repo.
You can push it to your GitHub repo, where it will live as a branch.

From the GitHub manual page:

To push a local branch to an established remote, you simply need to use

git push REMOTENAME BRANCHNAME 

If you don’t want to use the same name on the remote branch you can use

git push REMOTENAME LOCALBRANCHNAME:REMOTEBRANCHNAME.

b/ a fork is a repository clone on the GitHub side (which you can in turn clone on your desktop local side)

c/ If you want to compare branches between different forks on the GitHub side (since, again, forks only exist on the GitHub side; on your side, you are just cloning remote repo), you can!
(Well... you can since 2 days ago, July 15th, 2010):
Cross-Repository Compare View: the ability to compare branches across repositories.


Remember that with a DVCS, you have an extra dimension to branching: publication (push/pull from/to a remote repository)

Creating a branch does not mean having it visible for all others on GitHub.
It is just created locally on your own repo. The publication part is left to you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文