Git远程开发的使用流程
- 新建一个空文件夹
mkdir master - 初始化仓库
git init - 配置用户名
git config --global user.name "fengtianhe" - 配置邮箱
git config --global user.email "545704061@qq.com" - 查看当前工作目录状态
git status

如果git status告诉你有文件被修改过,用git diff可以查看修改内容。
- 创建分支
git checkout -b a

git checkout命令加上-b参数表示创建并切换,相当于以下两条命令:
git branch a //创建一个分支
git checkout a //切换分支
- 创建一个裸仓库
git clone --bare master master.git

- 本地克隆仓库
git clone fengtianhe@192.168.20.253:project/jyb_git/master.git

- 创建空文件
touch git.md markdown.md - 添加文件并提交加注释
git add 文件名
git commit -m '注释'

- 新建三个分支
git branch a1
git branch a2
git branch a3

- 克隆三个仓库,分别切换到a1,a2,a3目录下,分别对git.md文件进行编辑
- 将编辑后的文件进行提交(如果没有将编辑的文件添加到git列表,会有提示),所以先执行 git add 命令 在使用 git commit 进行提交

- commit命令提交是提交到本地的仓库,还需要进行推送执行 git push 命令

在没有设置 push.default 的时候提示你设置,如果没有设置,默认是simple参数
- a1用户已经提交使用 git log 查看修改内容

- 此时a2用户也编辑好了文件使用 git add git commit git push 进行提交

出现错误,其原因是a2起初clone的是一个干净的目录但是现在 现在a分支上有a1的版本,也就是说a上意境有最新的版本,解决的方法是使用 git pull 更新下版本
- 我们更新版本后会出现冲突

- 我们查看一下冲突文件

这是我解决后冲突后的文件

- 使用 git add git commit git push 进行提交;在a分支下使用 git log 查看日志文件

- 同样,在a3用户下编辑文件,解决冲突并提交,在a2下更新

- 重复多次,在不同分支下将git.md编辑完成
- 在上级分支,我们可以用 git log --graph 查看合并历史

网友评论