直接说每条命令了
git status是显示当前文件所处于的状态。
➜ /Users/alps/Sites/judianer/1 git:(master)>git status On branch master Your branch is up-to-date with 'origin/master'. nothing to commit, working directory clean
➜ /Users/alps/Sites/judianer/1 git:(master)>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
➜ /Users/alps/Sites/judianer/1 git:(master) ✗>git status On branch master Your branch is up-to-date with 'origin/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: README.md no changes added to commit (use "git add" and/or "git commit -a")
这里再说下git add命令,这个大家都很熟悉,就是把文件加入到追踪目标里,然后我们把修改过的READMD.md给git add再git status就变成:
➜ /Users/alps/Sites/judianer/1 git:(master) ✗>git add README.md ➜ /Users/alps/Sites/judianer/1 git:(master) ✗>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) modified: README.md
再说下git diff这个命令,这个其实很好理解,就是查看文件的不同,但是参数不同,查看的内容也不同。
假如不加任何参数,就是显示原始文件,和刚刚修改过后的文件(还没有git add,没有加入暂存区)的不同。
diff --git a/README.md b/README.md index ed1d3e3..cc05995 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,10 @@ just for fun. I want to do somthing. write by chen on 2014/07/24 + +========================= +If you have any advice. +send email to me. [email protected] + +write by chen on 2014/07.24 (END)
假如加入暂存区了,(就是git add之后),想查看可以用git diff --cached. 或者 git diff --staged这样就行了。
然后提一句,假如嫌git add麻烦,可以在直接git commit -a -m "commit content"这样直接提交~
git rm命令是用来删除文件的(之前的一篇博客里有讲),这里只说想要从远程仓库删除,但是要保留在本地目录。
所以就不仅仅是git rm了,要加个参数 --cached
➜ /Users/alps/Documents/github/TinyOS_Code git:(master)>git rm --cached 1.txt rm '1.txt' ➜ /Users/alps/Documents/github/TinyOS_Code git:(master) ✗>ls 1.txt RssiFromRadio cc2420 ep2 README.md RssiToRadio ep1 ep3
最后git mv filefrom fileto
这个是更改名字功能。
相当于
mv filefrom fileto git rm filefrom git add fileto
大致就这些~ 等下次可以写下git rebase神马的~