【问题标题】:define git alias for pulling remote branch为拉取远程分支定义 git 别名
【发布时间】:2016-10-01 01:19:14
【问题描述】:

我最近开始在我的工作流程中添加 git 别名,但还没有弄清楚如何处理以下场景。

我每天多次将最新的远程分支下拉到我的本地master,例如git pull git@github.com:Matt-Dionis/angular2-tour-of-heroes.git

我想做的是分配一个别名,例如git pull latest-tour,其中latest-tour 指的是该 ssh 地址。
有没有办法做到这一点?

【问题讨论】:

  • git remote add latest-tour git@github.com:Matt-Dionis/angular2-tour-of-heroes.git
  • 有很多方法可以做到这一点,但我会选择@JeffPuckettII 所说的:只需将它们添加为远程,然后您可以从它们git fetch,使用git log latest-tour/master 查看提交,合并和/或变基,等等。

标签: git bash command-line


【解决方案1】:

Git Basics - Working with Remotes 中所述,您可以add multiple remotes。默认情况下,git pull/fetch 将使用名为 origin 的遥控器。
但是您可以随时从您可能已定义的任何其他遥控器中获取。

正如Jeff Puckett所提到的:

 git remote add latest-tour git@github.com:Matt-Dionis/angular2-tour-of-heroes.git 
 git fetch latest-tour

你可以pull from a different remote and different branch:

git push latest-tour master

【讨论】:

  • 这是本地别名吗?还是添加到 repo 供其他人使用?
  • @eranotzap 是远程名称,即:本地配置设置,您可以在<path/to/my/local/repo>/.git/config 中看到。它是本地的,这意味着仅对您的本地存储库有效。不适合其他人。
猜你喜欢
  • 2015-04-24
  • 1970-01-01
  • 2012-03-03
  • 1970-01-01
  • 2012-03-21
  • 2011-10-28
相关资源
最近更新 更多