Git使用笔记

     2016年08月12日       江南兔子哥       运维笔记->系统管理       git 

常用操作

查看本地和远程的所有分支

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

学习资料