推送到 Bitbucket 存储库静默失败并且没有任何变化
过去我使用过 svn 和 cvs,但从未使用过 BitBucket 或 Git。我刚刚获得了一个 BitBucket 帐户,并关联了一个空项目。
我阅读了 Bitbucket 入门,并在我的 BitBucket 页面上看到我应该执行以下操作:
git clone https://bitbucket.org/REST_OF_URL/...
我使用 Git 提供的 URL;它成功地接受了我的密码,没有任何问题。但确实如此,打印以下内容:
警告:您似乎克隆了一个空存储库。
这对我来说很有意义,因为我刚刚注册了 BitBucket。
这将创建一个名为 myproject
的目录。然后,我将一个文件复制到该目录并将其添加到存储库:
cd myproject
echo 'Hello Git!' > hello.txt
git add hello.txt
我检查了状态:
git status
并看到 hello.txt 被识别为新文件。
然后我尝试将文件推送到服务器:
git push https://bitbucket.org/REST_OF_URL/...
再次输入我的密码,它没有抱怨。 上面写着:
一切都是最新的
,但该文件没有显示在我的在线 Git 项目中。我还注意到有一个 git commit 命令。我也尝试过:
git commit -m "Initial project set up"
输出如下:
您的姓名和电子邮件地址是根据以下内容自动配置的 您的用户名和主机名。请检查它们是否准确。
由于该文件仍未显示在我的目录中,我觉得我必须在自己的计算机上进行本地提交。 可以帮助我,告诉我
- 用 Git 设置一个简单的项目时缺少什么
- ,我在本地计算机上提交了这些文件(我的磁盘空间不足,不希望有任何混乱)
任何人都 用户从Git BitBucket 手册中获得的经验仅当您推送时
git push origin master
但是当您推送时不起作用
git push
这解决了我的问题,但我仍然不知道为什么会发生这种情况。
In the past I've used svn and cvs, but never BitBucket or Git. I just got a BitBucket account with an empty project associated.
I read Getting Started with Bitbucket and on my BitBucket page that I am supposed to do the following:
git clone https://bitbucket.org/REST_OF_URL/...
I use the URL provided by Git; it successfully accepts my password without any trouble. It does, however print the following:
warning: You appear to have cloned an empty repository.
This made sense to me, because I just signed up for BitBucket.
This makes a directory called myproject
. I then copied a file to that directory and added it to the repository:
cd myproject
echo 'Hello Git!' > hello.txt
git add hello.txt
I checked the status:
git status
and saw that hello.txt was recognized as a new file.
I then tried to push the file to the server:
git push https://bitbucket.org/REST_OF_URL/...
again, I typed in my password and it didn't complain.
It reads:
Everything up-to-date
But the file has not shown up in my online Git project. I also noticed there is a git commit
command. I tried this as well:
git commit -m "Initial project set up"
The output reads:
Your name and email address were configured automatically based on
your username and hostname. Please check that they are accurate.
Since the file still hasn't shown up in my directory, I feel like I must have made a local commit on my own machine. Can anyone help me by telling me
- What I'm missing to set up a simple project with Git
- Where I've committed these files on my local machine (I'm hard up for disk space and don't want any clutter)
As another user experienced from the Git BitBucket manual it transfers only when you push with
git push origin master
but does not work when you push with
git push
This resolves my issue, but I still do not know why this happens.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
简单的解决方案是首先使用 master 分支推送:
然后,您可以使用 git push 默认推送到 Bitbucket(master 分支)。
The simple solution is push with master branch at first time:
Then after that, you can use
git push
for default push to Bitbucket (master branch).git add
仅将文件添加到本地索引,以便准备好提交。您首先需要git commit
(您已经这样做了),然后git push
您的提交到BitBucket,这样它们就会显示在那里。您相信自己正在本地做出承诺,这是正确的。这也许是去中心化版本控制系统(DVCS)的定义特征之一。您的本地计算机上有项目历史记录的完整副本。当您
git push
时,您将在本地执行的提交发送到 BitBucket。您的项目文件夹的顶层应该有一个
.git
目录。这是所有元数据的去向。git add
only adds the file to your local index so that it is ready to be committed. You first need togit commit
(which you did), thengit push
your commits to BitBucket so they will show up there.You are correct in your belief that you are making commits locally. This is perhaps one of the defining features of a decentralized version control system (DVCS). You have a full copy of your project history on your local computer. When you
git push
, you send the commits you did locally to BitBucket.Your project folder should have a
.git
directory at its top level. This is where all the metadata is going.您可能想在 http://www.ava.co.uk/git 其中 9 个视频,平均每个视频大约 4 分钟,介绍基础知识并希望能够拉平陡峭的学习曲线...如果您发现这些视频有益,请随意推广此条目
You might like to check out these videos at http://www.ava.co.uk/git There are 9 of them, about 4 mins each on average, going through the basics and hopefully flattening a steep learning curve... Feel free to promote this entry if you find the videos beneficial
使用 Bitbucket,您还可以选择使用 Mercurial,它比 Git 更容易使用,而且其术语更接近 Subversion。我个人确实主要使用 Git,但为了完全掌握它的概念和实现,我付出了很大的努力,而且仍然如此。对我来说,Mercurial 更容易使用,尽管我过去从未使用过 Subversion。我从命令行使用 Git 和 Mercurial,所以这并不是对 CLI 的厌恶。
是的,您的提交始终是 Git 和 Mercurial 的本地提交,然后您将其推送到 Bitbucket 或其他服务器或托管解决方案。如果您希望继续使用 Mercurial,您可能需要阅读 Hg Init(甚至可能会在 Git 中派上用场,因为这些概念类似)至少阅读介绍分布式 SCM 与集中式模型的对比。如果您想要一本面向 Git 的资源或书籍,请考虑 Pro Git,但它写得不够好(或简短)作为Hg Init。
With Bitbucket you also have the option of using Mercurial which is both easier to use than Git and which keeps it's terminology closer to that of Subversion. I personally do use mostly Git but struggled mightily, and still do, to grasp it's concepts and implementation fully. For me Mercurial is much easier to use and this despite having never used Subversion in the past. I use both Git and Mercurial from the command line so this is not an aversion to the CLI.
Yes your commit is always local with both Git and Mercurial, you then push it to Bitbucket or other server or hosting solution. You may want to read Hg Init if you wish to pursue use of Mercurial (may even come in handy with Git since the concepts are similar) at least read the intro contrasting distributed SCM to the centralized model. If you want a Git oriented resource or book consider Pro Git but it is not as well written (or as brief) as Hg Init.