创建新仓库

在新文件夹中

git init

检出仓库

创建本地仓库的克隆版本

git clone path/to/repository

从远程服务器克隆

git clone username@host:/path/to/repository
如:
git clone git@github.com:shenxinle/myUtils.git
或
git clone https://github.com/shenxinle/myUtils.git

添加与提交

git add filename / git add *
git commit -m 'message'

提交到远程仓库

连接

git remote add origin <server>
如:
git remote add origin git@github.com:shenxinle/myUtils.git
git remote add origin https://github.com/shenxinle/myUtils.git

提交

git push origin master(or other branch)

分支

创建分支

git checkout -b newBranch

切回主分支

git checkout master

删除分支

git branch -d newBranch

删除远程分支

git push origin :newBranch

提交新分支到远程仓库

git push origin newBranch

更新与合并

更新本地仓库

git pull

合并分支

git merge <branch>

标签

创建标签

git tag 1.0.0 <commit id>
通过 git log 查看最近 commit 的 id