[英]How to push local changes to a remote git repository on bitbucket
我正在测试Git和Bitbucket。
我在Bitbucket上创建了一个存储库,并创建了一个repo的本地副本,并将文件提交到它中。 我似乎无法将文件从我的本地仓库推送到远程仓库。
这是我正在做的事情:
git clone https://me@bitbucket.org/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
之间的区别的任何解释?
请改用git push origin master
。
你在本地拥有一个存储库,并且最初的git push
正在“推送”它。 没有必要这样做(因为它是本地的)并且它显示所有内容都是最新的。 git push origin master
指定一个远程存储库( origin
)和位于那里的分支( master
)。
有关更多信息,请查看此资源 。
这是一种安全措施,可以避免推送尚未发布的分支。 简而言之,通过执行“git push”,只会推送已存在于同一名称服务器上的本地分支,或者使用localbranch:remotebranch语法推送的分支。
要将所有本地分支推送到远程存储库,请使用--all
:
git push REMOTENAME --all
git push --all
或指定要推送的所有分支:
git push REMOTENAME master exp-branch-a anotherbranch bugfix
此外,在“git push”命令中添加-u
非常有用,因为这将告诉您本地分支是在远程分支的前面还是后面。 在git fetch之后运行“git status”时会显示此信息。
我从Git下载了https://git-scm.com/并设置了ssh关注答案以获取说明https://stackoverflow.com/a/26130250/4058484 。
一旦在我的Bitbucket帐户中验证了生成的公钥,并参考http://www.bohyunkim.net/blog/archives/2518上解释的步骤,我发现只是'git push'正在运行:
git clone https://me@bitbucket.org/me/test.git
cd test
cp -R ../dummy/* .
git add .
git pull origin master
git commit . -m "my first git commit"
git config --global push.default simple
git push
壳牌响应如下:
$ git push
Counting objects: 39, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (39/39), done.
Writing objects: 100% (39/39), 2.23 MiB | 5.00 KiB/s, done.
Total 39 (delta 1), reused 0 (delta 0)
To https://me@bitbucket.org/me/test.git 992b294..93835ca master -> master
它甚至可以用于在GitHub中将master合并到gh-pages
git checkout gh-pages
git merge master
git push
含义“ git push
”命令的第二个参数(' master
') -
$ git push origin master
可以通过从' news-item
'分支启动“ push
”命令来明确。 它导致本地“ master
”分支被推送到远程“ master
”分支。 有关更多信息,请参阅
https://git-scm.com/docs/git-push
在哪里<refspec>
[<repository> [<refspec>…]
写的意思是“ specify what destination ref to update with what source object.
”。
供您参考,以下是我如何验证此声明的屏幕截图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.