简体   繁体   English

在 git 中将存储库分支与远程存储库同步

[英]Syncing repository branches with a remote repository in git

I just got a mac and I'm having issues with command line git.我刚买了一台 mac,但在使用命令行 git 时遇到了问题。 When I clone a repository, none of the branches are being tracked.当我克隆存储库时,没有跟踪任何分支。 Is there a way to clone a repository and also clone the branches locally?有没有办法克隆存储库并在本地克隆分支? I know that I can make a new local branch and track a remote branch, but I don't want to have to do that for every branch in the repository.我知道我可以创建一个新的本地分支并跟踪一个远程分支,但我不想对存储库中的每个分支都这样做。

$ git branch -a
* master
  remotes/origin/9PMComplete
  remotes/origin/HEAD -> origin/master
  remotes/origin/LinkUpdate
  remotes/origin/Safari
  remotes/origin/TableUpdate
  remotes/origin/Update_1.0.1
  remotes/origin/Update_1.0.2
  remotes/origin/master
  remotes/origin/onclick

Don't forget that remote tracking branches (the ones in refs/remotes/origin namespace) are not tracked locally on purpose.不要忘记远程跟踪分支( refs/remotes/origin命名空间中的分支)不是有意在本地跟踪的。
See " Tracking Branches and Remote Tracking Branches: Summary ".请参阅“ 跟踪分支和远程跟踪分支:摘要”。

Only the default branch of the remote repo is tracked locally.本地只跟踪远程仓库默认分支

That avoid having too many branches to deal with at the beginning.这样可以避免在开始时处理太多分支。

If you have to track all branches, see " Track all remote git branches as local branches "如果必须跟踪所有分支,请参阅“将所有远程 git 分支跟踪为本地分支

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM