1、创建本地库
git init . 新建库
git config --global user.email “hello@163.com”
git config --global user.name “laoer”
git config --global core.editor vim //将默认编辑器由nano更改为vim
2、提交
2.1 git add . 将当前目录下所有文件添加到提交缓冲区
2.2 git commit 将提交缓冲区中的数据提交到库中
如果没有将默认编辑器修改为vim,则进入nano文本编辑器(类似vim模式)后,填写修改记录,按下Ctrl+x,输入Y保存,然后回车退出
或者使用 git commit -m “提交修改信息”
3、分支操作
3.1 创建分支
git branch <name>
git checkout <name>
以上两条等同于:
git checkout -b <name>
3.2 切换分支
git checkout master //切换到master分支
3.3 合并分支
git checkout master
git merge <name> –no-ff //使用no-ff,会多生成一个commit 记录,并强制保留 <name> 分支的开发记录
关于-no-ff参见Git – Fast Forward 和 no fast foward
3.4 解决冲突
<合并时出现这个信息表示需要合并冲突:Automatic merge failed; fix conflicts and then commit the result.>
git status
可视化解决冲突:
git mergetool
3.5 删除分支
git branch -d <name>