【Github】的使用方法

在vscode中使用github

  1. git安装
    https://git-scm.com/download
  2. 从github上找到要clone的项目,新建写项目的文件夹,单击右键有一个git bash here之后进去输入git clone https://github.com/xxx/xxx.git
    之后在vscode中打开这个项目在命令行输入npm install
    安装依赖没有问题npm run dev
  3. 首次需要提交代码需要github的emali和名称。
    git config --global user.email "you@example.com"
    git config --global user.name "Your Name"
  4. 团队协作的提交代码方式
    git pull origin master
    git status
    git add *
    git commit -m “某某:提交…页面” --no-verify
    git push origin master

merger request分支处理

1.在vscode中先使用命令将代码提交到仓库
git pull origin dev_主分支
git checkout -b dev_新分支
git add
git commit -m '提交的内容 ’
git push origin dev_新分支

2.在GitLab中新建merger request
在这里插入图片描述
在这里插入图片描述

多人协作,pull代码报错解决方法

在团队开发中,如果多人协作,同一个文件已经被其他人提交到远程,且你又修改了改文件,需要进行如下操作。
当输入git pull origin dev_xxx
报错信息:

error: Your local changes to the following files would be overwritten by merge:
		src/global.css
        src/pages/home/chatContants/index.js
Please, commit your changes or stash them before you merge.

解决方案:

git stash//将本地修改隐藏
git pull origin dev_xxx
git stash pop//将本地修改显示

在eclipse中使用github。

  1. 第一次发布项目
    eclipse中选中项目单击右键选中Team
    team -> share project
    team -> add to index
    team -> commit
    team -> remote -> push
  2. 提交代码的方式
    team -> add to index
    team -> commit
    team -> push

commit时:
commit:不能单独的Push某一个文件,只能Push整个项目
commit and push:可以单独Push某一个文件

  1. 第一次下载项目
    File -> import -> clone
    在这里插入图片描述
    在这里插入图片描述
    更新代码时选择Team -> remote -> pull
  2. 解决冲突
    发现冲突,进入同步视图,在项目中右键Team->Synchronized Workspace
    添加到本地暂存 team -> add to index
    提交本地分支 team -> commit
    更新服务端的分支内容 到本地分支 team -> pull
    修改冲突:直接修改或者单击右键选择merge tool
    add to index
    commit push
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值