Git 分支不存在或创建后没有权限

Git branch doesn't exist or doesn't have permissions after creating

我创建了一个 b运行ch,运行 以下内容:

git push [branchname]

我得到了:

fatal: The current branch [branchname] has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream [branchname] [branchname]

那我运行:

git push --set-upstream [branchname] [branchname]

我得到了:

fatal: [branchname] does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

我该如何解决这个问题?我更喜欢终端解决方案,谢谢!

您当地的分支机构似乎没有上游。首先,使用

找出您的远程跟踪存储库
git remote -v

大多数时候你会得到

origin git@xxx (fetch)
origin git@xxx (push)

这意味着您有一个名为 origin 的遥控器。因此,您可以使用

将本地分支推送到远程
git push origin <local_branch_name>