如何开始通过git提交到bitbucket-看不到更改

如何开始通过git提交到bitbucket-看不到更改,git,version-control,Git,Version Control,也许我在这方面做得不对,但我仍然遵循git教程。我在bitbucket上有一个名为“testrepos”的存储库,我正在尝试使用它 首先,我用git克隆git克隆它https://my_username@org/my_username/testrepos.git 现在,回购协议是空的,所以我创建了一个名为main.cpp的文件。然后运行“git add main.cpp”。如果现在运行git status,我会看到一个名为main.cpp的新文件要提交 最后,我运行了git commit-m‘F

也许我在这方面做得不对,但我仍然遵循git教程。我在bitbucket上有一个名为“testrepos”的存储库,我正在尝试使用它

首先,我用git克隆
git克隆它https://my_username@org/my_username/testrepos.git

现在,回购协议是空的,所以我创建了一个名为main.cpp的文件。然后运行“git add main.cpp”。如果现在运行
git status
,我会看到一个名为main.cpp的新文件要提交

最后,我运行了git commit-m‘First commit’。有0个更改、0个插入和0个删除!为什么我的文件没有提交?我也在使用
push
pull

编辑以下是完整日志:

Welcome to Git (version 1.7.7-preview20111014)

Run 'git help git' to display the help index.
Run 'git help <command>' to display help for specific commands.

chris@EDI ~
$ cd git

chris@EDI ~/git
$ git clone https://my_username@bitbucket.org/my_username/testrepos.git
Cloning into testrepos...
Password:
warning: You appear to have cloned an empty repository.

chris@EDI ~/git
$ cd testrepos/

chris@EDI ~/git/testrepos (master)
$ git pull
Password:
Your configuration specifies to merge with the ref 'master'
from the remote, but no such ref was fetched.

chris@EDI ~/git/testrepos (master)
$ git add temp.cpp

chris@EDI ~/git/testrepos (master)
$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#       new file:   temp.cpp
#

chris@EDI ~/git/testrepos (master)
$ git commit -m 'Committing temp file'
[master (root-commit) 5d659df] Committing temp file
 Committer: unknown <chris@EDI.(none)>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 temp.cpp

chris@EDI ~/git/testrepos (master)
$ git pull
Password:
Your configuration specifies to merge with the ref 'master'
from the remote, but no such ref was fetched.

chris@EDI ~/git/testrepos (master)
$ git push
Password:
Everything up-to-date
欢迎使用Git(版本1.7.7-preview20111014)
运行“git help git”以显示帮助索引。
运行“git help”以显示特定命令的帮助。
chris@EDI ~
$cd吉特
chris@EDI~/吉特
$git克隆https://my_username@bitbucket.org/my_username/testrepos.git
克隆到testrepos。。。
密码:
警告:您似乎克隆了一个空存储库。
chris@EDI~/吉特
$cd测试报告/
chris@EDI~/git/testrepos(主)
$git拉力
密码:
您的配置指定与ref“master”合并
从远程,但没有获取这样的引用。
chris@EDI~/git/testrepos(主)
$git添加临时cpp
chris@EDI~/git/testrepos(主)
$git状态
#论分行行长
#
#初始提交
#
#要提交的更改:
#(使用“git rm--cached…”取消存储)
#
#新文件:temp.cpp
#
chris@EDI~/git/testrepos(主)
$git commit-m“提交临时文件”
[master(root提交)5d659df]提交临时文件
提交人:未知
您的姓名和电子邮件地址已根据自动配置
在您的用户名和主机名上。请检查它们是否准确。
您可以通过显式设置来抑制此消息:
git config--global user.name“Your name”
git config--全局user.emailyou@example.com
执行此操作后,您可以通过以下方式修复用于此提交的标识:
git提交--修改--重置作者
0个文件已更改,0个插入(+),0个删除(-)
创建模式100644 temp.cpp
chris@EDI~/git/testrepos(主)
$git拉力
密码:
您的配置指定与ref“master”合并
从远程,但没有获取这样的引用。
chris@EDI~/git/testrepos(主)
$git推送
密码:
一切都是最新的

您添加的文件是否为空?该消息将显示更改文件的数量以及插入和删除的行数。如果只是添加了一个空文件,git不会将其生成的数字视为“已更改”。但是,它确实提交了文件


尝试向上推到bitbucket,并在web浏览器中查看存储库文件列表。您应该在那里看到您的文件。

尝试
git-push-origin-master
您确实需要执行
git-push-origin-master
,而不仅仅是
git-push
。这是因为,
git push
的默认行为是将每个分支推送到远程端具有相同名称的分支,只要存在具有该名称的远程分支。在这种情况下,您的BitBucket存储库是完全空的(没有
master
分支,因为没有提交),因此默认的
git push
git push origin
行为不会推送分支。如果您执行以下操作,您的推送将起作用:

git push origin master
。。。但由于这是您的第一次推送,您应该:

git push -u origin master

。。。它还将
origin
中的
master
分支设置为
master
分支的默认上游分支。您只需要使用这种形式的命令一次。

我也遇到过这个问题,而且我看到了很多无用的建议。最后,我仔细阅读了git pull和git fetch的代码。在我的例子中,问题是由于在所讨论的远程设备的配置文件中有“tagopt=--tags”引起的。这似乎会导致git fetch执行“自动标记跟踪”,这在某些情况下会产生截断fetch_头文件的不良副作用。这反过来会导致git pull失败,并出现以下错误:

您的配置指定与ref“master”合并 从远程,但没有获取这样的引用

对于git的内部结构,我真的没有足够的信心来判断这是否是一个bug或预期的行为,或者仅仅是我对git不是很了解。但是,从我的配置文件中删除“tagopt”设置在所有情况下都解决了这个问题

注意,这尤其令人困惑,因为手动运行“git fetch--tags…”采用不同的代码路径,fetch_HEAD保持良好状态

(我正在运行git版本1.7.4.1)

git push-u原点——全部

第一次

git推送原点——全部

后来

比特桶101上列出了什么


这是我的问题。即使我事后尝试“git push”,我也不会在web浏览器中看到任何对回购的承诺。“还没有记录任何提交。”难道你不需要推拉来获取回购的数据吗?请发布你使用的所有命令的完整日志,从第一次“git pull”开始,包括cd命令等@Mark Hildreth我已经发布了所有命令的完整日志。谢谢。+1因为它解释了你为什么要推一次原始主机。+1因为这个解释。github对初始推送没有相同的要求。