如何将本地更改推送到 Bitbucket 上的远程 Git 存储库

发布于 2024-12-08 20:21:17 字数 625 浏览 0 评论 0原文

我正在测试 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

回梦 2024-12-15 20:21:17

使用 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.

峩卟喜欢 2024-12-15 20:21:17

这是一种安全措施,以避免推送尚未准备好发布的分支。宽松地说,通过执行“git Push”,只会推送服务器上已存在的同名本地分支,或者使用 localbranch:remotebranch 语法推送的分支。

要将所有本地分支推送到远程存储库,请使用 --all

git push REMOTENAME --all
git push --all

或指定要推送的所有分支:

git push REMOTENAME master exp-branch-a anotherbranch bugfix

此外,将 -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:

git push REMOTENAME --all
git push --all

or specify all branches you want to push:

git push REMOTENAME master exp-branch-a anotherbranch bugfix

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.

对你再特殊 2024-12-15 20:21:17

我使用的是从 https://git-scm.com/ 下载的 Git em> 和 设置ssh 按照答案获取说明https://stackoverflow.com/a/26130250/4058484

在我的 Bitbucket 帐户中验证生成的公钥后,并参考 http 上说明的步骤://www.bohyunkim.net/blog/archives/2518 我发现只有 'git Push' 正在工作:

git clone https://[email protected]/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

Shell 响应如下下面:

$ 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://[email protected]/me/test.git 992b294..93835ca  master -> master

它甚至可以在 GitHub 中推动合并 master 到 gh-pages

git checkout gh-pages
git merge master
git push

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:

git clone https://[email protected]/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

Shell respond are as below:

$ 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://[email protected]/me/test.git 992b294..93835ca  master -> master

It even works for to push on merging master to gh-pages in GitHub

git checkout gh-pages
git merge master
git push
○闲身 2024-12-15 20:21:17

git push”命令的第二个参数('master')的含义 -

git push origin master

可以通过从“news-item”启动“push”命令来明确分支。它导致本地“master”分支被推送到远程“master”分支。有关更多信息,请参阅git-push

其中

[<repository> [<refspec>…​]

意思是“指定要使用哪个源对象更新哪个目标引用”。

供您参考,这是我如何验证此声明的屏幕截图。

输入图片此处描述

The meaning of the second parameter ('master') of the "git push" command -

git push origin master

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> in

[<repository> [<refspec>…​]

is 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.

Enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文