尝试提交时“没有任何提交,工作目录干净”消息

Kur*_*eek 0 git github

我正在尝试按照教程创建博客网站 ( 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.
Run Code Online (Sandbox Code Playgroud)

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

kurt@kurt-ThinkPad:~/blogger$ ls
app  config     db       Gemfile.lock  log     Rakefile     test  vendor
bin  config.ru  Gemfile  lib           public  README.rdoc  tmp
Run Code Online (Sandbox Code Playgroud)

任何人都可以解释为什么我会收到“工作目录干净”错误?(也许还有随后的“致命:远程源已经存在”错误)?

PS 我知道 .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
Run Code Online (Sandbox Code Playgroud)

Kur*_*eek 6

我只是通过删除 .git 目录“重新开始”,

rm -rf .git
Run Code Online (Sandbox Code Playgroud)

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


Mos*_*yar 5

尝试通过在您的工作目录中执行以下操作来克隆您在 Github 上创建的存储库:

git clone https://github.com/khpeek/jumpstart-blogger.git
Run Code Online (Sandbox Code Playgroud)

然后运行这个:

git status
Run Code Online (Sandbox Code Playgroud)

看看,如果您的文件在那里但尚未添加,请运行:

git add .
git commit -m "First Commit"
Run Code Online (Sandbox Code Playgroud)

最后,再次检查 git status!

希望我有所帮助...