gpt4 book ai didi

git - 'origin' 似乎不是 git 存储库

转载 作者:太空狗 更新时间:2023-10-29 13:37:14 24 4
gpt4 key购买 nike

我关注了vogella tutorial about GIT ,第 17 节练习“使用(本地)远程存储库”。执行步骤 17.3 时,出现此错误:

The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream ../remote-repository.git master

执行的步骤是:

   $repo01>git clone --bare . ../remote-repository.git
Cloning into bare repository '../remote-repository.git'...
done.
$mkdir repo02
$\repo02>git clone ../remote-repository.git .
Cloning into '.'...
done.
$\repo01>git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: test01
modified: test02.txt

no changes added to commit (use "git add" and/or "git commit -a")
$repo01>git commit -a -m "Some changes"
$\repo01>git push ../remote-repository.git
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream ../remote-repository.git master

可能是什么原因?

最佳答案

正如 git 告诉你的:当前分支 master 没有上游分支。 因此,git 不知道它应该推送到你的 remote-repository 的哪个分支你的改变。

我无法重现这个;如果我执行你的步骤,就会设置上游分支。但是,要解决此问题,您可以完全按照 git 告诉您的方式进行操作:git push --set-upstream ../remote-repository.git master。这告诉 git 你当前正在处理的分支(你的本地 master)默认从你的远程存储库的 master 分支 pull 和推送。如果设置一次,推送将自动知道将来推送到哪里。

除了您在问题中提供的命令,您是否还执行过其他操作?

编辑:由于我对 push.default 的自定义设置,我可能无法重现此内容:我建议使用 $ git config --global push.default current< 将其设置为当前状态。这意味着 git 只推送当前分支并自动推送到具有相同名称的远程分支(如果存在)。参见 herepush.default 部分了解详细信息。

关于git - 'origin' 似乎不是 git 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42528544/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com