git使用技巧
1. 远程克隆 `git clone ...`
2. 检查状态 `git status`
3. 添加文件 `git add .`
4. 提交文件 `git commit -m 'xxx'`
5. 创建分支 `git branch <name>`
6. 切换分支 `git checkout <name>`
7. 查看分支 `git branch`
8. 删除分支 `git branch -d <name>`
9. 创建并切换分支 `git checkout -b <name>`
10. 合并分支(先切换到master)`git merge <name>`
11. 合并分支(防止丢掉分支信息)`git merge --no-ff -m 'xx' <name>`
12. 版本回退 `git reset --hard <commitId>` 或者 返回当前版本 `git reset --hard HEAD` , 返回上一个版本 `git reset --hard HEAD^`
13. 查看文件 `cat <filename>`
14. 查看文件改动 `git diff <filename>`
15. 推送分支到远程库 `git push origin <name>` 这里的 `origin` 是用 `git remote` 获取的信息
16. 本地拉取远程分支 `git checkout -b <name> origin/<name>`
17. 本地拉取文件 `git pull`
18. 查看分支信息 `git log` 或者 `git log --graph` 或者 `git log --graph
--pretty=oneline --abbrev-commit`
19. 查看某次提交的内容 `git show <commitId>`
20. 查看某次提交文件的内容 `git show <commitId> <filename>`
21. 保存目前分支现场,先去做别的事 `git stash`
22. 查看当前分支所有stash `git stash list`
23. 恢复指定的stash `git stash apply stash@{x}` 然后删除 `git stash drop` 或者 `git stash pop`
24. 查看远程库的信息 `git remote` 或者 `git remote -v`
25. 创建一个标签 `git tag <tagname>` ,也可以指定一个commit id `git tag <tagname> <commitId>` , 打标签的时候指定标签信息 `git tag -a <tagname> -m 'xxx'`
26. 查看所有标签 `git tag`
27. 查看标签信息 `git show <tagname>`
28. 本地删除标签 `git tag -d <tagname>`
29. 推送标签到远程库 `git push origin <tagname>` 或者一次性推送全部标签 `git push origin --tags`
30. 删除远程标签 `git tag -d <tagname>` -> `git push origin :refs/tags/<tagname>`
31. 使用`git log`命令时如何退出这个命令呢? 按一下键盘 `q` 即可退出
32. 有时候合并分支会出现界面被锁住的情况,这时处理方法: 先按 `ESC`,再输入 `:wq`,按一下 `Enter` 键即可退出
33. 出现 `warning: LF will be replaced by CRLF in ...` 提示时,设置
`git config --global core.autocrlf false` 或者 `git config --global core.safecrlf false` 消除提示
34. 有时`.gitignore`配置文件不生效,原因是某些文件已经被纳入了版本管理中,做法是删除本地缓存文件 `git rm -r --cached`
#### npm使用技巧
1. 查看配置 `npm config ls`
1. 设置淘宝代理 `npm config set registry https://registry.npm.taobao.org/`
#### 码云特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目
5. 码云官方提供的使用手册 [http://git.mydoc.io/](http://git.mydoc.io/)
6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)