我使用github的时间相对较短,我总是使用客户端来执行提交和拉取。昨天我决定从git bash中尝试一下,我成功地创建了一个新的repo和提交文件。

今天我从另一台计算机上对存储库进行了更改,我已经提交了更改,现在我回到了家,并执行了git拉来更新我的本地版本,我得到了这个:

There is no tracking information for the current branch.
    Please specify which branch you want to merge with.
    See git-pull(1) for details

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream develop origin/<branch>

这个回购的唯一贡献者是我,没有分支(只有一个主)。我在窗口上,我已经执行了从git bash的拉:

git 状态:

$ git status
# On branch master
nothing to commit, working directory clean

git 分支:

$ git branch
* master

我做错了什么?


当前回答

这个答案是最好的

谁希望将他们的回购链接到他们的项目并提交更改

作为椰子的答案

步骤1

git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=<remote>/<branch> master

步骤2

git branch -u origin/master
Branch 'master' set up to track remote branch 'master' from 'origin'.

步骤3

git pull
Already up to date.

这个问题

我花了几个小时提交更改 我遵循了上面的步骤 和 Git添加。Git提交。 然后我执行下面的步骤,我的推动是成功的

推动变革

执行

git push -f origin master

其他回答

这个答案是最好的

谁希望将他们的回购链接到他们的项目并提交更改

作为椰子的答案

步骤1

git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=<remote>/<branch> master

步骤2

git branch -u origin/master
Branch 'master' set up to track remote branch 'master' from 'origin'.

步骤3

git pull
Already up to date.

这个问题

我花了几个小时提交更改 我遵循了上面的步骤 和 Git添加。Git提交。 然后我执行下面的步骤,我的推动是成功的

推动变革

执行

git push -f origin master

ComputerDruid的答案很好,但我认为没有必要手动设置上游,除非你想这样做。我加上这个答案是因为人们可能认为这是必要的一步。

如果你像下面这样指定你想要拉动的遥控器,这个错误就会消失:

git pull origin master

注意,origin是远程的名称,master是分支的名称。


1) 如何检查遥控器的名称

git remote -v

2)如何查看存储库中可用的分支。

git branch -r

try

   git pull --rebase

希望这个答案对你有帮助,原来的答案在这里https://stackoverflow.com/a/55015370/8253662

有了Git 2.24(2019年Q4),你就不必这么做了

git branch --set-upstream-to=origin/main main
git pull

你将能够做到:

git pull --set-upstream-to=origin/main main

参见“默认远程和分支使用-u选项-适用于推而不是拉”。


注意,在Git 2.37 (Q3 2022)中,你有一个新的选项push.autoSetupRemote

git config --global push.autoSetupRemote true

然后,一个简单的git push将与git push——set-upstream-to=origin/main main相同,使下一个git pull已经设置为从origin/main检索提交。

Git分支——set-upstream-to=origin/main