
创建仓库
git init在当前目录执行,会生成 .git目录文件,这个和SVN一致。
git commit -m "first commit"-m:表示提交描述,必须要填。
git remote add origin git@github.com:test/test.gitgit push -u origin master直接从远端把代码克隆下来。
git clone git@github.com:test/test.gitgit status$ git status
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
README.md
nothing added to commit but untracked files present (use "git add" to track)git pull就等同下面。
git fetch
git mergegit add
添加指定文件:
git add test.txt Test.java添加所有文件:
git add .git reset HEAD -- filename
git reset HEAD -- Test.java这样Test.java将不会被提交到仓库中。
git rm [--cached] fileName
默认会取消并删除文件, --cached表示不删除文件。
git mv filename1 filename2该文件必须被add到仓库中才能操作。
git log
$ git log
commit a3eb048ca74c3881f70264de90671d95474f241e (HEAD -> master, origin/master, origin/HEAD, javastack)
Author: javastack <javastack@qq.com>
Date: Fri Sep 22 10:38:37 2017 +0800
commit
commit 75336d6769e79581af8aefe2a15c9b2f305064c5
Author: javastack <javastack@qq.com>
Date: Wed Sep 20 11:19:29 2017 +0800git branch
git branch test1.0git checkout
git checkout test1.0git checkout -b
git checkout -b test1.0git branch
$ git branch
* master
test1.0git branch -d
git branch -d test1.0合并到主干。
git merge
git merge test1.0git push origin
git push origin test1.0git diff
git diff master test1.0