Git 不识别任何远程分支

标签 git github version-control git-remote

首先,我一生中总共使用 Git 大约 3 天。看了很多书,基本了解了一些。

所以我们正在尝试设置一个暂存服务器。工作流程应如下所示“本地 -> 暂存 -> 实时”

我的本​​地机器可以连接到 git 仓库,它可以看到所有分支,并允许我推送分支。实时服务器可以看到分支并 pull/merge 。登台服务器能够克隆主服务器,并且可以看到 remotes/origin/{以及此处的其他一些内容}。但是登台服务器看不到所有分支。

我已经尝试获取,我已经硬重置,我已经设置了一个跟踪分支,以及 SO 和谷歌建议的任何其他事情。我不知道如何在这里进行。

这是我在本地对“branch -a”的输出:

$ git branch -a
* all-to-staging
  choose-all
  country-route
  master
  select-to-autocomplete
  sharebuttons
  remotes/origin/HEAD -> origin/master
  remotes/origin/all-to-staging
  remotes/origin/choose-all
  remotes/origin/country-route
  remotes/origin/master
  remotes/origin/select-to-autocomplete
  remotes/origin/sharebuttons
  remotes/origin/tablesaw
  remotes/origin/wrapping-blockquotes

这是我的分期结果:

# git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/live
  remotes/origin/master

我什至可以看到 all-to-staging 分支:

all-to-staging ``

如何让我的暂存站点识别 all-to-staging 分支,以便我可以 pull 它并让人们看到更改?

最佳答案

所以我想通了,希望这对以后的其他人有所帮助。

使用 git remote -v 我意识到我的来源指向实时站点,而不是我的存储库。

有了这些知识,我遵循了本指南 https://help.github.com/articles/changing-a-remote-s-url/使用以下命令更改远程 url:

git remote set-url origin https://github.com/{my username}/{my repo}.git

SSH 类似,如果你的 repo 是私有(private)的,那么这样做可能会更好

git remote set-url origin git@github.com:{my username}/{my repo}.git

使用 git remote -v 检查你的来源,你应该看到你的新来源 url

现在这里有两件事要做,正确的做法是创建一个新目录并再次 pull 下你的 repo,这样 git 基本上就设置好了,看起来像这样: 光盘.. mkdir {新项目目录} cd {新建项目目录} git clone git@github.com:{我的用户名}/{我的仓库}.git git 分支 -a git checkout {你的分支名称} pull

第二种方法比较棘手,因为您可能会遇到问题,但有时项目设置非常复杂,值得在重新设置之前冒险。 (这是我必须做的来解决我的问题)

使用 git branch -a 检查分支,如果你仍然没有看到你的分支,那么你需要获取 git fetch 然后你应该看到你的分支,你可以使用 git checkout

切换到你选择的分支

它看起来像这样:

git branch -a
{no branches shown}
git fetch
git branch -a
{all branches shown}
git checkout {your-branch-name}
git pull

关于Git 不识别任何远程分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27136352/

相关文章:

git - .bashrc 未被 git bash 读取 git 2.5.1

git - 什么是 'dirty' 子模块?

git - 如何在git中用错误的作者重命名提交

github - 通过Google Cloud Source Control自动部署Google Cloud Functions

windows - Git:如何仅共享存储库中选定的文件夹和文件以允许 2 个团队协作,但不共享整个代码库?

git - 无法使用 CLI 登录到 heroku

authentication - 为 GitHub 创建 SSH key ?

git - 添加所有非受控文件?

version-control - 你如何 "check out"代码?

version-control - 与分布式源代码控制的持续集成