提交没有出现在github上

Joh*_*ino 15 git github

  • 我在github上创建了一个新的存储库.
  • 我选择了添加README.md的其中一个选项.
  • 然后我在硬盘上插入项目.
  • 我在/Users/myusername/github/myproject/.git/中运行了git init:初始化的空Git存储库
  • 我跑了"git add".然后"git commit -m'project files'",回复了这个:

    [master (root-commit) ca52fe0] project files
     981 files changed, 257939 insertions(+), 0 deletions(-)
     create mode 100644 index.php
     create mode 100644 license.txt
     create mode 100644 readme.html
     create mode 100644 wp-activate.php
     ...
    
    Run Code Online (Sandbox Code Playgroud)
  • 然后我跑了"git remote add origin https://github.com/myusername/myproject.git "
  • 然后我跑了"git push origin master"
  • 然后我运行了"git status",没有任何提交

但我看看回购和我的"我的项目文件"提交不存在.那么我运行git pull并得到了这个:

You asked me to pull without telling me which branch you
want to merge with, and 'branch.master.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.
Run Code Online (Sandbox Code Playgroud)

然后git push再次检查,仍然我的提交不在github repo上.我唯一能看到提交的是我运行"git log"时:

MacBook-myproject myusername$ git log
commit ca52fe090e6dbf1b6aa6ee51c3283efbe7549904
Author: User <myemailaddress>
Date:   Sat Jun 23 19:22:05 2012 -0400
project files
Run Code Online (Sandbox Code Playgroud)

我尽可能地遵循github指示.我究竟做错了什么?

Chr*_*ert 13

在创建了Github存储库之后(即你可以在Github上查看它),那么你应该已经拥有:

  • 本地存储库设置: git init
  • 创建README文件并将其添加到存储库:

touch README
git add README
git commit -m 'first commit'

  • 一个名为origin链接到您的存储库的远程:

git remote add origin https://github.com/username/repo.git

  • 初始推送,将本地README复制到Github存储库:

git push -u origin master

如果您可以在Github上查看您的存储库,那么它已成功创建.在这种情况下,您可能已经使用在线编辑工具在Github上编辑了README文件,这导致您的远程和本地分支发生分歧.在将本地更改推送到Github之前,您需要获取或拉取远程更改,在本地合并更改(自动合并pull),然后推送到远程.

请参阅Pro Git:从遥控器中取出和拉出