參考:
1.http://www.lxweimin.com/p/118ce8bc6eee
2.http://www.lxweimin.com/p/97946d9df5bd
CREAT(創建)
//在當前目錄下創建一個本地庫(Create a new local repository)
git init
//在遠程庫克隆一個本地庫(Clone an existing repository)
git clone?ssh://user@domain.tld/repo.git
Configuration(配置)
//設置提交時附帶的名字(Set the name attached to all your commits)
git config [--global]user.name
//設置提交時附帶的email(Set the email attached to all your commits)
git config [--global]user.email
//設置命令行輸出回執的顏色(Set colorzition of?command line output for all repository)
git config --globalcolor.ui auto
//獲取當前庫設置的用戶名(Print set name(in currentrepository or globally))
git config [--global]user.name
//獲取當前庫設置的email(Print set email(in current repositoryor ?globally))
git config [--global]user.email
Local Changes(本地操作)
//查看工作區內的文件修改(List changed files in yourworking directory)
git status
//查看已追蹤文件的修改(List changed to trackedfiles)
git diff
//添加此文件的所有修改在下次提交時(Add allcurrent changed in file to the next commit)
git add
//添加本地庫中的所有修改在下次提交的時(Add allcurrent changed to the next commit)
git add .
//修改文件名并添加到下次提交當中(Rename file and add it tonext commit)
git mv
//刪除此文件并將此處刪除添加到下次提交當中(Delete fileand add its deletion to next commit)
git rm
//提交工作區所有文件(Commit all local changes in tracked files)
git commit -a
Commit History(提交歷史)
//顯示所有的提交日志(Show all commits)
git log
//這個文件的最后一次提交日志(Shwo changes over time fora specific file)
git log –p
//這個提交者最后一次的提交日志(Show changes over time fora specific committer)
git log--author=
//此文件被誰修改了(Who changed what and when in file)
git blame
//查看臨時的文件變動(Store changes temporarily)
git stash
//刪除上一次記錄儲蓄新的改動記錄(Remove and apply changes)
git stash pop
//把此文件從過去的提交記錄中刪除但是保留當前本地的文件(Remvoe filefrom previous commits but keep it locally)
git rm --cached
Branches & Tags(分支和標簽)
//本地所有的分支列表(List all existing branches)
git branch
//切換分支(Switch HEAD branch)
git checkout
//創建新分支(Creat a new branch based on your currentHEAD)
git branch
//創建一個新的分支基于一個遠程的分支(Creat a new?tracking branch based on a remote branch)
git branch --track
//刪除一個本地分支(Delete a local branch)
git branch -d
//刪除一個遠程分支(Delete a remote branch)
git branch origin --delete
//重命名遠程分支名(Rename a branch on remote)git push
git push :
//
git push
//給當前提交打一個tag,也可以查看當前標簽(Tag the current commit)
git tag
Update & Publish(更新和提交)
//查看遠程庫的地址列表(List all currentlyconfigured remotes)
git remote -v
//查看這個遠程庫的信息(Show information about a remote)
git remote show
//添加新的遠程庫(Add new remote repository)
git remote add
//重命名遠程庫(Rename a remote)
git remote rename
//從遠程庫更新所有的信息到本地,但是不合并(Download allchanges from remote,but don't merge into HEAD)
git fetch
//從遠程庫更新所有的信息到本地,但是不合并并清理已刪除的遠程分支(Download all changes fromm remote,but don't merge inHEAD and clean up deleted branchs from origin)
git fetch -p
//從遠程庫更新數據并立即合并數據(Download changes and directly merge into HEAD)
git pull
//將本地數據同步到遠程庫中(Publish local changes on aremote)
git push
//追蹤一個遠程庫(Track a remote repository)
git remote add --track
//同步標簽到遠程庫(Publish your tags
git push --tags
//顯示遠程庫信息(Show information about a submodule)
git remote show
Merge & Rebase(分支合并和重整數據)
//將其他分支和并到當前分支(Merge branch into yourcurrent HEAD)
git merge
//將親她分支合并到當前分支并按照提交順序排序(Rebase your current HEAD onto branch)
git rebase
//終止當前合并(Abort a rebase)
git rebase –abort
//解決沖突后繼續當前合并和重整(Continue a rebase afterresolving confilcys)
git rebase –continue
//使用配置的合并工具解決沖突(Resolve conflicts using your configured merge tool)
git mergetool
//手動解決沖突使用編輯器并標記已解決的文件
git add
//
git rm
Undo(撤銷)
//丟棄所有的本地修改(Discard all local changes in your workingdirectory)
git reset --hard HEAD
//丟棄此文件的本地修改(Discard local changes in aspecific file)
git checkout HEAD
//撤銷某次的提交內容(Revert a commit by providing a new commit with contrary changes)
git revert?
//撤銷某次提交的某個文件的內容(Revert a specific filefrom a previous commit)
git checkout
重置頭指針到過去的某個提交上,版本回退(Reset your HEAD pointer to a previous commit)
//回退到某個版本(Discarding local changes)
git reset --hard?
//回退到某個版本并保存未追蹤的改動
git reset
//回退到某個版本并保存未提交的改動
git reset --keep