git add [some files] # add [some files] to staging area
git add [some more files] # add [some more files] to staging area
git commit # commit [some files] and [some more files]
如果你想让这个提交在两个分支上都可用,你就得这么做
git stash # remove all changes from HEAD and save them somewhere else
git checkout <other-project> # change branches
git cherry-pick <commit-id> # pick a commit from ANY branch and apply it to the current
git checkout <first-project> # change to the other branch
git stash pop # restore all changes again
$ git status
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: file1
modified: file2
modified: file3
modified: file4
将文件添加到登台
$ git add file1 file2
检查一下你所提交的内容
$ git status
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: file1
modified: file2
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: file3
modified: file4
使用提交消息提交文件
$ git commit -m "Fixed files 1 and 2"
如果您不小心提交了错误的文件
$ git reset --soft HEAD~1
如果你想撤销文件重新开始
$ git reset
Unstaged changes after reset:
M file1
M file2
M file3
M file4