git常用命令收集
Mac
用户家目录下 .gitconfig
1 | git config --gloabl user.name "VaneHay" ## 全局 |
创建并初始化
1 | mkdir test |
创建分支
1 | git branch abc |
查看分支
1 | git branch -al |
重命名分支
1 | git branch -m oldName newName |
恢复已删除的分支
1 | git log -g //查看提交的 commit |
reset 与的区别
1 | git reset 的作用是修改HEAD的位置,目标版本之后提交的版本会不见 |
合并
1 | git checkout master //切换master分支 |
例子:使用命令行创建仓库
1 | git clone git@e.coding.net:vanehay/test/test.git |
例子:使用命令行推送已存在的仓库
1 | git remote add origin git@e.coding.net:sxydkj/test/test.git |
例子:更换远程仓库地址方法
1 | 1. 通过命令直接修改远程仓库地址 |
例子:分之的创建、删除、切换、合并
1 | git branch -a 查看所有分支 |
例子:使用回退的方式解决 error: Your local changes to the following files would be overwritten by merge:
问题
1 | 1.进入到文件所在文件目录,或者能找到文件的路径 |
例子:git pull
单一文件
1 | git fetch origin master |