{"title": "Git\u4f7f\u7528\u7b14\u8bb0", "update_time": "2016-08-12 15:41:48", "tags": "git", "pid": "300", "icon": "linux.png"}
## 常用操作 查看本地和远程的所有分支 ``` git branch -a ``` Checkout远程分支 ``` git checkout -b localserverfix origin/remoteserverfix ``` 删除本地分支 ``` git branch -d branch_tobe_deleted ``` 合并分支到master ``` git checkout master git merge branch_tobe_merged ``` 推送本地分支到远程分支 ``` git push origin localserverfix:remoteserverfix ``` 删除远程分支 ``` git push origin :remoteserverfix ``` 重新设置origin 地址 ``` git remote set-url origin git@remote_git_repo:xxx.git ``` 查看特定commit的具体变化 ``` git show commit-id ``` 取消add ``` git reset HEAD file-to-cancel-add ``` git status和git diff显示颜色,在 ~/.gitconfig下追加如下内容 ``` [alias] lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative st = status [color] branch = auto diff = auto status = auto [color "branch"] current = yellow reverse local = yellow remote = green [color "diff"] meta = yellow bold frag = magenta bold old = red bold new = green bold [color "status"] added = yellow changed = green untracked = cyan ``` ## 学习资料 * 可视化学习的好工具 http://www.opstool.com/git/