怎么从现有的目录中创建git仓库?
使用 git init 命令:
$ git init
Initialized empty git repository in /home/wm/project/wm_git_book/.git/
git中的文件有那些状态?
被git管理的工作目录中的文件无非两种状态:已跟踪或者未跟踪。
已跟踪的文件是指那些被git管理的文件,在上一次快照中有他们的记录。已跟踪的文件可的状态能是未修改的、已修改的或者已暂存的。
工作目录中除了已跟踪的文件,其余全是未跟踪的文件。
怎样查看文件状态?
使用 git status 命令:
$ git status
On branch master
Initial commit
nothing to commit (create/copy files and use "git add" to track)
怎样暂存和提交文件?
使用 git add 和 git commit 命令:
$ git add README.txt
$ git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: README.txt
$ git commit -m "Add README.txt"
[master (root-commit) bf47a4f] Add README.txt
1 file changed, 1 insertion(+)
create mode 100644 README.txt
更多内容戳原文。