git的起源是什么意思,我会误解什么? [英] What does origin mean in git, and what do I misunderstand?

查看:105
本文介绍了git的起源是什么意思,我会误解什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用bitbucket,我认为在理解其结构时遇到了问题.

对我来说,我有一个名为ABC的新存储库,我添加了一些基本的归档,提交和推送原始主机.现在,最新消息是我的出身/主人,对吧?

现在,我想创建一个名为D的分支并对其进行处理.当我完成工作时,我承诺,现在我想按逻辑将其推给我的主人.我不想把它推到起源.对我来说,似乎我必须将所有东西都推向原点,而我不明白为什么.对我而言,Origin就像是一个里程碑,但是我想在基本项目构建的第一个推动程序中保留Origin.

然后,我将创建一个分支E并对其进行处理.最后,对我来说结构应该是这样的.

这里有一幅希望展示我的想法的小图片:

http://s7.postimg.org/k1f5q4b13/git_explanaition.jpg

更新:对于那些了解德语的人 https://www.youtube.com/watch?v=0Im_FrvLxXo 这也帮助我充分了解了该系统.

解决方案

您的术语令人困惑.您不会将事情推到分支机构.您将事物合并为分支.您按下远程.

origin是您的远程的名称.简单来说,这就是您从中克隆的存储库.这是一个有两个遥控器的示例:

amb@nimrod-ubuntu:~/git-publish/git-publish$ git remote -v show
github  git@github.com:abligh/git-publish.git (fetch)
github  git@github.com:abligh/git-publish.git (push)
origin  https://github.com/stefanha/git-publish.git (fetch)
origin  https://github.com/stefanha/git-publish.git (push)

(不必担心用于提取和推送的单独条目).您可以看到我克隆了stefanha的名为git-publish的github存储库,然后进行了一些更改将其推到了我自己的github存储库(同名).

因此,您可以在本地分支之间进行合并,并从远程存储库中进行推/拉/取.提取从远程存储库中获取更改,而提取(大致)则将其合并到本地跟踪分支中.推送会将您的更改合并到远程存储库的本地副本,然后将您的更改推送到远程存储库.

如果您创建一个新分支D,并已对其进行更改,那么您可以使用它做两件事(嗯,可能还有更多,但我们还是坚持一下吧):

  • 您可以将分支D合并到本地主机中.然后您可能希望也可能不希望将master推入原点.

  • 您可以将D推到原点,因此原点现在有两个分支.为此,您第一次需要告诉git在何处推送,即执行git push -u origin D而不是仅仅git push. -u告诉它跟踪上游分支,即下次执行git pull时从那里拉.

我在这里做了一些简化,但是基本上就是这样.

I just started using bitbucket and I think I got a problem understanding the structure of it.

For me, I have a new repo called ABC, I added some basic filed, commit and push origin master. Now The latest push is my origin/master, right?

Now I wanna create a branch called D and work on it. When I finished the work, I commit, and now I wanna push this logically to my master. I don't wanna push it to origin. For me it looks like I have to push everything to origin and I don't understand why. For me Origin is like a milestone, but I wanna keep the origin on the first push my basic project build.

Then I'm going to create a branch E and work on it. Finally, for me the structure should be like this.

Here a small picture hopeful to show how I think:

http://s7.postimg.org/k1f5q4b13/git_explanaition.jpg

Update: For those of you who understand German https://www.youtube.com/watch?v=0Im_FrvLxXo this also helped me alot understanding the system.

解决方案

Your terminology is confusing. You don't push things to branches. You merge things into branches. You push to remotes.

origin is the name of your remote. In simple terms, that's a repository you have cloned from. Here's an example where there are two remotes:

amb@nimrod-ubuntu:~/git-publish/git-publish$ git remote -v show
github  git@github.com:abligh/git-publish.git (fetch)
github  git@github.com:abligh/git-publish.git (push)
origin  https://github.com/stefanha/git-publish.git (fetch)
origin  https://github.com/stefanha/git-publish.git (push)

(don't worry about the separate entries for fetch and push). You can see I cloned stefanha's github repo called git-publish, then having made some changes pushed it to my own github repo (same name).

So you merge between your local branches, and push/pull/fetch from remote repositories. A fetch fetches changes from a remote repository, and a pull (roughly) fetches then merges them into a local tracking branch. A push merges your changes to the local copy of the remote repo and pushes your changes to the remote repo.

If you create a new branch D, and have committed a change set to it, then there are two things you could do with it (well, there are probably more, but let's stick with the obvious):

  • You could merge the branch D into your local master. You might or might not then wish to push master to origin.

  • You could push D to origin, so origin now has two branches. To do this, the first time you need to tell git where to push, i.e. do git push -u origin D rather than just git push. The -u tells it to track the upstream branch, i.e. pull from there when you next do a git pull.

I've simplified a bit here, but that's basically it.

这篇关于git的起源是什么意思,我会误解什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆