Git命令提交项目代码

1、首先进入项目的主分支

2、Fork一份工程,当做自己的项目管理分支


Git命令提交项目代码_第1张图片

3、在电脑上创建一个文件夹,先Clone一份自己工程的项目分支

git clone git@godinsec.gitlab.com:yongfei.wang/SELand_Vertu

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

      git branch看看当前的分支

      git checkout -b develop  切换到develop分支,因为我要pull拉去develop分支上的项目

5、然后在将自己的项目分支同步项目主分支(我们项目分支为develop分支)

git pull git@godinsec.gitlab.com:MobileTerminal/SELand_Vertu develop

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

git status是哪些文件有所修改

git diff 可以查询所修改的代码

git add -A 增加自己所做的修改

git commit -a 提交所有修改的代码

git push origin develop 提交代码

Git命令提交项目代码_第2张图片


7、最后在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@godinsec.gitlab.com:MobileTerminal/SELand_Vertu develop先同步一下会出现以上的错误

2、pull会使用git merge导致冲突,需要将冲突的文件resolve掉 git add -u,

3、在项目中看看哪些代码是对方改的,哪些代码是自己修改的,在合并成一份最新的代码

4、git commit之后才能成功



你可能感兴趣的:(Git命令提交项目代码)