尝试提交时"Nothing to commit, working directory clean"消息



我正在尝试按照教程来创建博客网站(http://tutorials.jumpstartlab.com/projects/blogger.html),但是在遵循我的步骤时遇到一些错误。我已经创建了一个空的存储库https://github.com/khpeek/jumpstart-blogger,并希望将代码从~/blogger目录推向其。我尝试了以下命令:

kurt@kurt-ThinkPad:~/blogger$ git init
Reinitialized existing Git repository in /home/kurt/blogger/.git/
kurt@kurt-ThinkPad:~/blogger$ git add .
kurt@kurt-ThinkPad:~/blogger$ git commit -m "first blogger commit"
On branch master
nothing to commit, working directory clean
kurt@kurt-ThinkPad:~/blogger$ git remote add origin git@github.com:khpeek/jumpstart-blogger.git
fatal: remote origin already exists.

首先让我感到困惑的是"工作目录清洁"警告,因为目录中有内容:

kurt@kurt-ThinkPad:~/blogger$ ls
app  config     db       Gemfile.lock  log     Rakefile     test  vendor
bin  config.ru  Gemfile  lib           public  README.rdoc  tmp

任何人都可以阐明为什么我会遇到"工作目录清洁"错误?(也许也可能在随后的"致命:远程来源已经存在"错误上?

P.S。我知道.gitignore文件在这里可能很重要。它的内容如下:

# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
#   git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config.
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
# Ignore all logfiles and tempfiles.
/log/*
!/log/.keep
/tmp

我刚开始'开始',通过删除.git目录,

rm -rf .git

并重新运行命令。这可以正常工作(我仍然必须为我的GitHub帐户添加一个SSH密钥),尽管我不确定为什么它以前不起作用。

尝试通过在工作目录中执行此操作来克隆您在github上创建的回购:

git clone https://github.com/khpeek/jumpstart-blogger.git

然后运行此:

git status

请参阅,如果您的文件在那里并且尚未添加,请运行:

git add .
git commit -m "First Commit"

最后,再次检查git状态!

希望我帮助...

最新更新