Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git Bitbucket文档在撒谎_Git_Github_Bitbucket - Fatal编程技术网

Git Bitbucket文档在撒谎

Git Bitbucket文档在撒谎,git,github,bitbucket,Git,Github,Bitbucket,在Bitbucket官方网站上,我们可以阅读: 在本地,更改到现有源的根目录。 通过在中运行以下命令来初始化项目 终端: git init git add--all git提交-m“初始提交” 登录 Bitbucket服务器并创建新的存储库。 在中找到克隆URL 左侧的导航面板(例如: /您的项目/repo.git)。 通过在中运行以下命令,将文件推送到存储库 终端(相应更改URL): git远程添加源 吉特 推u原点主控完成!您的存储库现在在中可用 比特桶服务器 资料来源: 在这之后,我得到

在Bitbucket官方网站上,我们可以阅读:

在本地,更改到现有源的根目录。
通过在中运行以下命令来初始化项目 终端:

git init
git add--all git提交-m“初始提交”
登录 Bitbucket服务器并创建新的存储库。
在中找到克隆URL 左侧的导航面板(例如: /您的项目/repo.git)。
通过在中运行以下命令,将文件推送到存储库 终端(相应更改URL):

git远程添加源
吉特 推u原点主控完成!您的存储库现在在中可用 比特桶服务器

资料来源:

在这之后,我得到了:

To https://bitbucket.org/myrepo/myapp.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://myrepo@bitbucket.org/myrepo/myapp.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
所以现在我要试着去拿

git fetch origin
再三
git-push-u原始主机

我得到了

> To https://bitbucket.org/myrepo/myapp.git 
> ! [rejected]        master -> master (non-fast-forward) error: failed
> to push some refs to 'https://myrepo@bitbucket.org/myrepo/myapp.git'
> hint: Updates were rejected because the tip of your current branch is
> behind hint: its remote counterpart. Integrate the remote changes
> (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note
> about fast-forwards' in 'git push --help' for details.

有人能帮我吗?我为这个git浪费了太多的时间

您可以始终使用
git push--force
强制将远程主机设置为本地主机

您可能有一些本地存储库中不存在的文件

使用
git push--force
可以覆盖更改。在其他情况下要小心,但在这里它可以工作,因为除了本地更改之外,您不希望在master上有任何内容

当然,您可以尝试使用
git pull
,然后再推一次就可以解决问题了


但这只是问题的答案,而不是关于bitbucket文档的问题。

git fetch origin
还不够,您必须运行
git merge origin/master
才能推送。

您收到的错误消息是因为存储库已经存在提交。如果您使用的是bitbucket.org(cloud bitbucket)而不是bitbucket服务器,它会为您创建一个read me。这会在repo中放入一个commit,这将阻止您引用的步骤工作。如果在对Bitbucket进行最新更新后执行repo时repo为空,则这些步骤有效,新创建的远程和本地存储库将不会具有相同的基础。所以你必须用下面的命令拉

git pull origin master --allow-unrelated-histories 

然后,您可以将本地分支推送到远程。

该问题与远程存储库上有不在本地存储库中的更改有关。这可能是因为远程存储库是独立于本地版本创建的。有几种方法可以实现这一点,所以请看一下这里的答案Bitbucket没有撒谎,这是新回购协议的文档,而不是已经有历史的回购协议。