Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 gitosis 设置并使用 ssh 工作得很好。git@domain.com:repository.git 按预期工作。可以克隆、推、拉等。
我想知道我是否可以使用 git 来拉一个特定的分支。例如 git@domain.com:repository.git/somebranchname
不知道这是否可行,也没有找到任何例子,所以我猜不是,但不确定。
不,当你克隆一个 Git 存储库时,你会得到所有东西(所有标签和分支)。但是,它们将存储为远程分支。假设远程的名称是origin(默认情况下),您可以使用以下命令签出本地分支:
origin
$ git checkout -b somebranchname origin/somebranchname
这将创建一个名为的本地分支somebranchname,其中包含somebranchnameGitosis 的 repo 副本中的内容。它还将“跟踪”远程分支,因此git pull将继续引入最新的更改。
somebranchname
git pull