自集中式的svn淡出历史舞台后,分布式的git成为前端重要的代码版本管理工具,熟练使用并理解其经常使用命令能提高咱们的开发效率。 如下枚举一些我经常使用的git命令。前端
git clone repo_url
复制代码
git branch --contains commitId
复制代码
git log
复制代码
git log --pretty=oneline
复制代码
git blame filename
复制代码
git add .
复制代码
git commit -m "description"
复制代码
git commit --amend
复制代码
git push
复制代码
git push origin --delete branchName
复制代码
git init
复制代码
ls -ah
复制代码
git reset --hard HEAD^
复制代码
git reset HEAD^
复制代码
git reset commitId
复制代码
git reset --hard commitId
复制代码
git revert commitId
复制代码
git status
复制代码
git status -s
复制代码
git checkout branchName
复制代码
git checkout --readme.txt
复制代码
git rm a.txt
复制代码
git remote set-url <new git repository url>
git remote -v 查看提交地址
git push 提交到新的地址
复制代码
gti branch
复制代码
git branch -a
复制代码
git branch -r
复制代码
git checkout -b dev origin/dev
复制代码
git chekcout test.js
复制代码
git push origin name
复制代码
git remote -v
复制代码
git remote rm originName
复制代码
git remote add origin url
复制代码
将须要提交的代码 add commit后,将未add的修改提交到一个缓存区,此时能够pull远程代码,pull 后 push 本地修改git
git stash
复制代码
git stash list
复制代码
git stash pop
复制代码
git stash clear
复制代码
git stash -u
复制代码
git stash save “备注”
复制代码
git stash drop
复制代码
git cherry-pick commitId
复制代码
git remote add originName originUrl
复制代码
git remote remove originName
复制代码
git push originName branchA:branchA
复制代码
git config --global --list
复制代码
git config user.name
复制代码
git config user.email
复制代码
git merge branchName
复制代码
git fetch
复制代码
git tag
复制代码
git rebase -i commitId
复制代码
git branch -m oldName newName
复制代码
git diff branchA branchB --stat // 展现文件路径及修改量
git log branchA ^branchB // 展现B比A多的commit
复制代码
git branch --contains commitId
复制代码
如今前端主流的编辑器VScode支持大部分的git快捷操做,具体使用命令行仍是界面按钮看我的的偏好,重点仍是理解git暂存区、分支、以及diff原理(字符串的最小编辑距离)等。缓存