红客VIP(http://www.):git常用命令总结(工作中常用到的) git命令有很多我们要介绍的许几篇文章都写不完了,这里整理了一些常用的git命令了,这些命令非常的实用对工作会有帮助的。
用git也好久了,感觉平时也就是git commit,git pull ,git push ,git add,git submodule,git stash,git branch,git checkout,git merge 等等,下面这个总结是分类进行的,比较清楚明了。 创建 复制一个已创建的仓库:
$ git clone ssh://haorooms@domain.com/blog.git
$ git init 显示工作路径下已修改的文件:
$ git status
$ git diff
$ git add
$ git add -p <file>
$ git commit -a
$ git commit
$ git commit -m 'message here'
git commit --date="`date --date='n day ago'`" -am "Commit Message"
$ git commit --amend
git stash 从当前目录的所有文件中查找文本内容:
$ git grep "Hello"
$ git grep "Hello" v2.5 从最新提交开始,显示所有的提交记录(显示hash, 作者信息,提交的标题和时间):
$ git log
$ git log --oneline
$ git log --author="username"
$ git log -p <file>
$ git blame <file> 列出所有的分支:
$ git branch
$ git checkout <branch>
$ git checkout -b <branch>
$ git branch <new-branch>
$ git branch --track <new-branch> <remote-branch>
$ git branch -d <branch>
$ git tag <tag-name> 列出当前配置的远程端:
$ git remote -v
$ git remote show <remote>
$ git remote add <remote> <url>
$ git fetch <remote>
$ git remote pull <remote> <url>
$ git pull origin master
$ git push remote <remote> <branch>
$ git push <remote> :<branch> (since Git v1.5.0)
$ git push --tags 将分支合并到当前HEAD中:
$ git merge <branch>
$ git rebase <branch>
$ git rebase --abort
$ git rebase --continue
$ git mergetool $ git add <resolved-file>
$ git rm <resolved-file> 放弃工作目录下的所有修改:
$ git reset --hard HEAD
$ git reset HEAD
$ git checkout HEAD <file>
$ git revert <commit>
$ git reset --hard <commit>
$ git reset <commit> $ git reset --keep <commit> |
|