oschian---git本地项目上传步骤



  1.              在git上创建项目
                       oschian---git本地项目上传步骤 
oschian---git本地项目上传步骤

复制git地址:

oschian---git本地项目上传步骤

2.在本地创建文件夹

F:\demo

接下来,做以下操作:打开终端,切换到你的项目目录下,依次输入以下命令

git init .
git pull [email protected]:xxxx/Demo.git
git add -A .
git commit -am "纳入版本控制"s
git push [email protected]:xxxxxxx/Demo.git master



常用命令:

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

      git branch看看当前的分支

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

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

git pull [email protected]:xxxxxxx/Demo.git develop

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

git status是哪些文件有所修改

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

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

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

git push origin develop 提交代码


warning:最后在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 [email protected]:xxxxxxx/Demo.git  master 先同步一下会出现以上的错误

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

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

4、git commit之后才能成功