如何将本地更改推送到 Bitbucket 上的远程 Git 存储库
我正在测试 Git 和 Bitbucket。
我已经在 Bitbucket 上创建了一个存储库,并创建了该存储库的本地副本,并且我正在将文件提交到其中。我似乎无法将文件从本地存储库推送到远程存储库。
这就是我正在做的:
git clone https://[email protected]/me/test.git
cd test
touch dummy
git add dummy
git commit dummy -m "my first git commit"
git push
最后一行输出:
Everything up-to-date
当我登录到 Bitbucket 时,我看不到我的虚拟文件。
我做错了什么?
这样做是有效的:
git push origin master:master
这和简单的 git push 之间的区别有何解释?
I'm testing out Git and Bitbucket.
I've created a repository on Bitbucket and have created a local copy of the repository and I am committing files into it. I can't seem to push the files from my local repository to the remote repository.
Here's what I'm doing:
git clone https://[email protected]/me/test.git
cd test
touch dummy
git add dummy
git commit dummy -m "my first git commit"
git push
The final line outputs:
Everything up-to-date
And when I log on to Bitbucket I can’t see my dummy file.
What am I doing wrong?
Doing this worked:
git push origin master:master
What is the explanation as to the difference between this and a simple git push
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 git push origin master 代替。
您在本地有一个存储库,并且初始的 git Push 正在“推送”到它。没有必要这样做(因为它是本地的)并且它会显示所有内容都是最新的。
git Push origin master
指定远程存储库 (origin
) 和位于该处的分支 (master
)。有关更多信息,请查看此资源。
Use
git push origin master
instead.You have a repository locally and the initial
git push
is "pushing" to it. It's not necessary to do so (as it is local) and it shows everything as up-to-date.git push origin master
specifies a a remote repository (origin
) and the branch located there (master
).For more information, check out this resource.
这是一种安全措施,以避免推送尚未准备好发布的分支。宽松地说,通过执行“git Push”,只会推送服务器上已存在的同名本地分支,或者使用 localbranch:remotebranch 语法推送的分支。
要将所有本地分支推送到远程存储库,请使用
--all
:或指定要推送的所有分支:
此外,将
-u
添加到“ git push”命令,因为这会告诉您本地分支是在远程分支之前还是之后。当您在 git fetch 后运行“git status”时,会显示此信息。This is a safety measure to avoid pushing branches that are not ready to be published. Loosely speaking, by executing "git push", only local branches that already exist on the server with the same name will be pushed, or branches that have been pushed using the localbranch:remotebranch syntax.
To push all local branches to the remote repository, use
--all
:or specify all branches you want to push:
In addition, it's useful to add
-u
to the "git push" command, as this will tell you if your local branch is ahead or behind the remote branch. This is shown when you run "git status" after a git fetch.我使用的是从 https://git-scm.com/ 下载的 Git em> 和 设置ssh 按照答案获取说明https://stackoverflow.com/a/26130250/4058484。
在我的 Bitbucket 帐户中验证生成的公钥后,并参考 http 上说明的步骤://www.bohyunkim.net/blog/archives/2518 我发现只有 'git Push' 正在工作:
Shell 响应如下下面:
它甚至可以在 GitHub 中推动合并 master 到 gh-pages
I'm with Git downloaded from https://git-scm.com/ and set up ssh follow to the answer for instructions https://stackoverflow.com/a/26130250/4058484.
Once the generated public key is verified in my Bitbucket account, and by referring to the steps as explaned on http://www.bohyunkim.net/blog/archives/2518 I found that just 'git push' is working:
Shell respond are as below:
It even works for to push on merging master to gh-pages in GitHub
“
git push
”命令的第二个参数('master
')的含义 -可以通过从“news-item”启动“push”命令来明确分支。它导致本地“master”分支被推送到远程“master”分支。有关更多信息,请参阅git-push。
其中
的意思是“指定要使用哪个源对象更新哪个目标引用”。
供您参考,这是我如何验证此声明的屏幕截图。
The meaning of the second parameter ('
master
') of the "git push
" command -can be made clear by initiating "push" command from the 'news-item' branch. It caused local the "master" branch to be pushed to the remote 'master' branch. For more information, refer to git-push.
Where
<refspec>
inis written to mean "specify what destination ref to update with what source object."
For your reference, here is a screen capture how I verified this statement.