create & clone
命令 |
作用 |
git init |
create new respository |
git clone /path/to/respository |
clone local respository |
git clone username@host:/path/to/respository |
clone remote respository |
add&remove
git add files 把文件的修改添加到暂存区
命令 |
作用 |
git add <filename> |
add changes to INDEX |
git add * |
add all changes to INDEX |
git rm <filename> |
remove/delete |
commit&synchronize
git commit 把暂存区的修改提交到当前分支,提交之后暂存区就被清空了
命令 |
作用 |
git commit -m "Commit message" |
commit change |
git push origin mater |
push changes to remote respository |
git remote add origin <server> |
connect local respository to remote respository |
git push |
update local respository with remote changes |
branches
git checkout -- files 使用暂存区的修改覆盖工作目录,用来撤销本地修改
命令 |
作用 |
git checkout -b <branch> |
create new branch |
git checkout master |
switch to master branch |
git branch -d <branch> |
delete branch |
git push origin <branch> |
push branch to remote respository |
merge
命令 |
作用 |
git merge <branch> |
merge changes from another branch |
git diff <source_branch> <target_branch> |
view changes between two branches |
tagging
命令 |
作用 |
git tag <tag> <commit ID> |
create tag |
git log |
get commit IDs |
restore
命令 |
作用 |
git checkout -- <filename> |
replace working copy with latest from HEAD |