Git/Github tips

Github配置

Github上同步fork和orignal

同步master

  1. git remote -v
  2. git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
  3. git remote -v
  4. git fetch upstream
  5. git checkout master
  6. git merge upstream/master

同步branch

  1. git checkout upstream/{branch}
  2. git checkout -b {local_branch}
  3. git merge upstream/{branch} {local_branch}

命令别名

https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases

  • git config --global alias.co checkout
  • git config --global alias.br branch
  • git config --global alias.ci commit
  • git config --global alias.st status

  • git reset --hard origin/master: 恢复到origin/master
  • git config --global credential.helper wincred: 缓存用账号,避免push时每次输入(用https地址clone,每次都要求输入账号)
  • git config --global core.autocrlf true: 去除mac os和windows换行符的diff (http://stackoverflow.com/questions/1889559/git-diff-to-ignore-m)
  • git config core.filemode false: 去除old and new mode diff (http://stackoverflow.com/questions/1257592/how-do-i-remove-files-saying-old-mode-100755-new-mode-100644-from-unstaged-cha)

你可能感兴趣的:(Git/Github tips)