在我的笔记本电脑上克隆我自己的 git 存储库后,无法看到新创建的分支

发布于 2024-12-16 19:49:37 字数 174 浏览 1 评论 0原文

我在桌面上设置了一个安全的 git 存储库设置,我可以从任何地方访问和克隆它。然而,克隆存储库后,我只能看到 master 分支,而看不到我在桌面上创建的新 dev 分支(这是我的 git 服务器)。需要明确的是,服务器上的开发分支还没有任何数据,但在我的笔记本电脑上克隆该存储库后,我至少期望看到它存在。

请帮忙!!

I have setup a secure git repo setup on my desktop which I am able to access and clone from anywhere. However after cloning the repository I can only see the master branch and not the new dev branch that I have created on my desktop (which is my git server). Just to be clear the dev branch on the server does not have any data yet, but I was atleast expecting to see that it exists, after cloning that repo on my laptop.

Please help!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无声静候 2024-12-23 19:49:37

完成克隆后,执行以下操作:

git checkout -b dev origin/dev

这将创建并切换到 dev 分支。

如果您正在谈论在克隆存储库上创建分支,请

git checkout <branch_name>

切换到该分支。

After you do the clone, do:

git checkout -b dev origin/dev

This will create and switch to the dev branch.

If you are talking about having created the branch on the clone repo, do

git checkout <branch_name>

to switch to the branch.

墨落画卷 2024-12-23 19:49:37

您可以使用以下命令查看所有现有分支:

git branch -a

对于基本存储库(仅限主分支),输出为:

* master                  ---> local master branch
  remotes/origin/master   ---> remote master branch

在简单的 gitbranch dev 后, gitbranch -a 的输出> 应该是:

  dev                     ---> local dev branch
* master                  ---> local master branch
  remotes/origin/master   ---> remote master branch

如果你想在远程存储库上创建一个分支:

git push origin <local branch name>:<remote branch name>

或者如果你想保留本地分支的名称:

git push origin <local branch name>

并且 git Branch -a 应该给出:

  dev                     ---> local dev branch
* master                  ---> local master branch
  remotes/origin/dev      ---> remote dev branch
  remotes/origin/master   ---> remote master branch

You can see all the existing branches with :

git branch -a

For a basic repository (master branch only), the output is :

* master                  ---> local master branch
  remotes/origin/master   ---> remote master branch

After a simple git branch dev, the output of git branch -a should be :

  dev                     ---> local dev branch
* master                  ---> local master branch
  remotes/origin/master   ---> remote master branch

If you want to create a branch on your remote repository :

git push origin <local branch name>:<remote branch name>

Or if you want to keep the name of the local branch :

git push origin <local branch name>

And git branch -a should give :

  dev                     ---> local dev branch
* master                  ---> local master branch
  remotes/origin/dev      ---> remote dev branch
  remotes/origin/master   ---> remote master branch
美男兮 2024-12-23 19:49:37

您需要首先从原始存储库中推送分支:

git push origin branchname

然后从新克隆中获取:

git fetch origin #origin is optional if that's the only remote you have

现在在本地创建并签出分支:

git checkout -t origin/branchname

You need to push your branch up first from the original repo:

git push origin branchname

Then fetch from the new clone:

git fetch origin #origin is optional if that's the only remote you have

Now create and checkout the branch locally:

git checkout -t origin/branchname
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文