Git 命令提交项目代码处理冲突

来源:互联网 发布:淘宝app首页流量来源 编辑:程序博客网 时间:2024/05/29 21:28

1.在电脑上创建一个文件夹,先Clone一份自己工程的项目分支,master 为主分支

$ Git clone git@xxxx.gitlab.com:xxxxxx/master

2.进入项目的二级目录进入git客户端,确认要pull分支

$ git branch //查看当前的分支$ git checkout -b develop  //切换到develop分支,因为我要pull的是develop分支上的项目

3.将自己的项目分支同步项目主分支(develop分支)

$ git pull git@xxx.gitlab.com:xxx/master develop

4.每次提交代码时候,需要先同步项目主分支代码

$ git status //是哪些文件有所修改$ git diff //可以查询所修改的代码$ git add -A //增加自己所做的修改$ git commit -a //提交所有修改的代码$ git push origin develop //提交代码

5.最后在new merge request,提交给相应的负责人,进行merge代码

错误解决:

如果某个同事提交代码,老大没有及时merge代码,自己也提交该文件的代码,那么老大merge代码会有冲突

会差生如下的错误提示:

Pull is not possible because you have unmerged files.Please, fix them up in the work tree, and then use 'git add/rm <file>'as appropriate to mark resolution, or use 'git commit -a'.

可以这样修改:
1、git pull git@xxx.gitlab.com:xxx/master 先同步一下会出现以上的错误
2、pull会使用git merge导致冲突,需要将冲突的文件resolve掉 git add -u,
3、在项目中看看哪些代码是对方改的,哪些代码是自己修改的,在合并成一份最新的代码
4、git commit之后才能成功

参考链接:http://blog.csdn.net/u013210620/article/details/50318225

原创粉丝点击