其实拉Git [英] Actually pulling with git

查看:114
本文介绍了其实拉Git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在GitHub中有一个git repo。我一直主要使用 git gui 来管理它,但现在我开始使用shell了。我想知道的是,我如何获取远程中的所有分支并自动将它们合并到本地回购库中的相应分支中?例如,如果我有分支 master development ,并且因此 origin / master origin / development ,我想获取 origin / master 并将它合并到 master 并获取 origin / development 并将其合并到 development 中。 / p>

有没有这样的命令?

解决方案

列出本地分行:

  $ git分行
*主行行

列出可用的远程分支:

  $ git branch -r 
* master
branch1
branch2

现在变得有趣了,跟踪远程分支1:

  $ git branch --track branch1 

这使得拉也可以在本地更新分支。



只需切换到新分支:

  $ git checkout branch1 

通过使用--track参数,远程分支被添加到.git / config并且将变得执着。即这只需要做一次。 .git / config中的相关条目将如下所示:

  branch.master.remote =原始
分支。 master.merge = refs / heads / master
branch.branch1.remote = origin
branch.branch1.merge = refs / heads / branch1

通过为每个远程分支运行分支--track命令,您希望在本地执行您想要的操作。


I have a git repo in GitHub. I've been mostly using git gui to manage it up to now, but now I'm starting to use the shell. What I want to know is, how do I fetch all the branches in a remote and merge them into the respective branches on my local repo automatically? For example, if I have branches master and development, and thus origin/master and origin/development, I want to fetch origin/master and merge it into master and to fetch origin/development and merge it into development.

Is there a command that does this?

解决方案

To list the local branches:

$ git branch
*  master

To list available remote branches:

$ git branch -r
* master
  branch1
  branch2

Now it gets interesting, To track a remote branch1:

$ git branch --track branch1

This enables a pull to also update the branch locally.

Simply switch to the new branch with:

$ git checkout branch1

By using the --track parameter, the remote branches are added to .git/config and will become persistent. ie this only needs to be done once. The pertinent entries from .git/config will show like this:

branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.branch1.remote=origin
branch.branch1.merge=refs/heads/branch1

By running branch --track commands for each of the remote branches you would like to have locally will do exactly what you want.

这篇关于其实拉Git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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