标签:
git add a.file
git commit -m "Commit Staged files"
$ git status # On branch master nothing to commit (working directory clean)
$ touch test.txt
$ git status # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # test.txt nothing added to commit but untracked files present (use "git add" to track)
$ echo "Add content to end of the a.txt" >> a.txt
$ git status # On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: a.txt # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # test.txt no changes added to commit (use "git add" and/or "git commit -a")
$ git add test.txt
$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: test.txt # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: a.txt #
$ git add a.txt
$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: a.txt # new file: test.txt #
git commit
# Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: a.txt # new file: test.txt
$ git commit [master d15838d] Commit the changes 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 test.txt
$ git commit -m "Add new files"
$ git commit -am "Add and then Commit"
$ git rm b.txt rm 'b.txt'
$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # deleted: b.txt #
$ git commit -m "delete b.txt" [master 2daa294] delete b.txt 0 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 b.txt
$ ls a.txt c.txt d.txt test.txt
$ git rm --cached d.txt rm 'd.txt'
$ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # deleted: d.txt # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # d.txt
$ git commit -m "remove d.txt from git" [master d625705] remove d.txt from git 1 files changed, 0 insertions(+), 1 deletions(-) delete mode 100644 d.txt
$ git status # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # d.txt nothing added to commit but untracked files present (use "git add" to track)
$ git log commit d62570527d545ae2677708ac2f9b015aab2df86f Author: linmiansheng <sheepjtgjfc@163.com> Date: Tue Jun 17 14:31:10 2014 +0800 remove d.txt from git commit 2daa294a500bf9b3b0af7fe586353d882f0c3592 Author: linmiansheng <sheepjtgjfc@163.com> Date: Tue Jun 17 14:27:50 2014 +0800 delete b.txt commit d15838d91e2c09e5e25a0a348e4dfb27c7e6b928 Author: linmiansheng <sheepjtgjfc@163.com> Date: Tue Jun 17 14:18:28 2014 +0800 Commit the changes commit b52882cca685b024991dec8b976c35a1cbc6c9cf Author: linmiansheng <sheepjtgjfc@163.com> Date: Tue Jun 17 14:11:13 2014 +0800
标签:
原文地址:http://www.cnblogs.com/gcczhongduan/p/4208711.html