Git的使用(二)提交以及分支的创建与合并

1. 提交:首先,转到昨天创建的仓库文件夹里,而后咱们建立一个gitCommit.txt文件,选择编辑文件,输入New File!2019/7/10 20:44(随便输入什么,我这个随便打的)。而后在GitBash里面,输入如下命令。回车以后,文件就已经上传至仓库了。git

$ git add gitCommit.txt
$ git commit -m '新文件的提交'

2. 分支的建立:咱们输入如下命令,这样咱们就建立了一个分支dev。code

$ git branch dev

接着执行如下命令查看全部的分支,回车以后会显示全部的分支。it

$ git branch

而后执行如下命令切换到分支devast

$ git checkout dev

3. 分支的合并:分支的合并语句很是简单,首先将分支切换到master,而后执行如下命令。文件

$ git merge master
Auto-merging gitCommit.txt
CONFLICT (content): Merge conflict in gitCommit.txt
Automatic merge failed; fix conflicts and then commit the result.

    这个时候,GitBash会提示出现冲突(我干的),而后看一下gitCommit.txt文件co

New File! 2019/7/10 20:41
<<<<<<< HEAD
Branch Dev: New File! 2019/7/10 20:56
=======
Master: New File! 2019/7/10 20:57
>>>>>>> master

咱们只须要删去<<<<<<<<<代码段A=========代码段B>>>>>>>>>>>>>咱们只须要解决这中间的代码冲突就完事儿了。上传

接着执行如下命令。冲突解决!commit

$ git add gitCommit.txt
$ git commit -m 'OK'
相关文章
相关标签/搜索