$ git config --global user.name "Yoour Name"$ git config --global user.email "email@example.com"
git config命令的--global参数,用了这个参数,表示你这台机器上所有的Git仓库都会使用这个配置,当然也可以对某个仓库指定不同的用户名和Email地址。
$ mkdir learngit$ cd learngit$ pwd/Users/michael/learngit
$git init
$ git add readme.txt
$ git commit -m "wrote a readme file"
$ git status
$ git diff
$ git log$ git log --pretty=oneline
$ git reset --hard HEAD^$ cat readme.txt
$ git reset --hard commit id$ cat readme.txt
$ git reflog
$ git diff HEAD -- readme.txt
$ git checkout -- readme.txt
$ git reset HEAD readme.txt
$ git rm test.txt
$ git remote add origin git@github.com:AnswerLiu/learngit.git
$ git push -u origin master
$ git push origin master
$ git clone git@github.com:AnswerLiu/test.git$ cd test$ lsREADME.md
$ git branch
$ git branch <name>
$ git checkout <name>
$ git checkout -b <name>
$ git merge <name>
$ git branch -d <name>
$ git log --graph$ git log --graph --pretty=oneline --abbrev-commit
$ git merge --no-ff -m "xxxx" <name>$ git log --graph --pretty=oneline -abbrev-commit
$ git stash
$ git stash list
$ git stash apply$ git stash drop
$ git stash pop
$ git stash apply stash@{0}
$ git branch -D <name>
$ git remote
$ git remote -v
$ git checkout -b dev origin/dev
$ git pull
$ git branch --set-upstream branch-name origin/branch-name
$ git tag <name>
$ git tag
$ git tag <name> commit id
$ git show <tagname>
$ git tag -a <tagname> -m "说明文字" commit id
$ git tag -s <tagname> -m "说明文字" commit id
$ git tag -d <tagname>
$ git push origin <tagname>
$ git push origin --tags
先从本地删除$ git tag -d <tagname>再从远程删除$ git push origin :refs/tags/<tagname>
$ git config --global color.ui true
$ git add -f <name>
$ git check-ignore -v <name>
$ git config --global alias.<别名> <name>
$ git config --global alias.st status$ git config --global alias.co checkout$ git config --global alias.ci commit$ git config --global alias.br branch$ git config --global alias.unstage ‘reset HEAD‘$ git config --global alias.last ‘log -1‘$ git config --global alias.lg ‘log --color --graph --pretty=format:‘%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset‘ --abbrev-commit‘
每个仓库的Git配置文件都在.git/config文件中当前用户的配置文件在用户主目录下的一个隐藏文件/gitconfig
原文:http://www.cnblogs.com/answer-liu/p/6364059.html