我正在学习git,已经参加了这个练习:
将
.gitignore
文件提交到您的存储库。提示:跑步git commit -am
还不够。为什么不?
我已经做了git commit -am
,这似乎足够了。
michael@michael:~/repos/website$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: breaching_whale.jpg
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
no changes added to commit (use "git add" and/or "git commit -a")
michael@michael:~/repos/website$ git add .
michael@michael:~/repos/website$ ls
images index.html README.md
michael@michael:~/repos/website$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: .gitignore
deleted: breaching_whale.jpg
michael@michael:~/repos/website$ git commit -am "Add gitignore"
[master e7cc08c] Add gitignore
2 files changed, 1 insertion(+)
create mode 100644 .gitignore
delete mode 100644 breaching_whale.jpg
michael@michael:~/repos/website$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working directory clean
您能推测一下我做错了什么,并帮助我理解本教程中的含义git commit -am
吗?为什么还不够?
这不是您做错事的情况。git commit -am
将所有跟踪的文件添加到提交中,并将消息作为参数提供给m
。您在git add .
此命令之前(可能自动)执行了该命令,该命令还将未跟踪的文件从当前目录添加到提交中。
为了清楚起见,跟踪文件是Git已经在监视更改的文件,而未跟踪文件是Git可以看到的但没有历史记录的文件。git commit -a
仅靠自己运行不会将新文件添加到存储库中,而只是将更改提交到Git已经知道的文件中。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句