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 "[email protected]"
    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
Github的使用方法_第1张图片
Github的使用方法_第2张图片

多人协作,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
    Github的使用方法_第3张图片
    Github的使用方法_第4张图片
    更新代码时选择Team -> remote -> pull
  2. 解决冲突
    发现冲突,进入同步视图,在项目中右键Team->Synchronized Workspace
    添加到本地暂存 team -> add to index
    提交本地分支 team -> commit
    更新服务端的分支内容 到本地分支 team -> pull
    修改冲突:直接修改或者单击右键选择merge tool
    add to index
    commit push

你可能感兴趣的:(Github)