1. GitHub操作

  • GitHub 网址:https://github.com/

1.1 创建远程库

  1. 登录GitHub
  2. 远程打开github仓库的vscode插件 github远程仓库地址_git

    远程打开github仓库的vscode插件 github远程仓库地址_git_02

  3. 创建远程仓库
  4. 远程打开github仓库的vscode插件 github远程仓库地址_git_03


  5. 远程打开github仓库的vscode插件 github远程仓库地址_远程仓库_04


  6. 远程打开github仓库的vscode插件 github远程仓库地址_github_05

  7. public是所有人都可以读,private是指定的人可以读。但是写的话只有团队内的人才可以写入。

远程仓库创建成功:

远程打开github仓库的vscode插件 github远程仓库地址_git_06


2. 远程仓库操作

远程打开github仓库的vscode插件 github远程仓库地址_github_07


2.1 查看当前所有远程地址别名

1)基本语法:

git remote -v

2)案例实操:

远程打开github仓库的vscode插件 github远程仓库地址_github_08


远程打开github仓库的vscode插件 github远程仓库地址_远程仓库_09


2.2 创建远程仓库别名

https://github.com/CQUT-yingyan-ZTJ/git-project01.git这个就是远程仓库地址

远程打开github仓库的vscode插件 github远程仓库地址_远程仓库_10

起别名后,我们以后可以直接使用别名来拉取项目

1)基本语法:

git remote add 别名 远程地址

别名建议和项目名一致

2)案例实操:

git remote add git-project01 https://github.com/CQUT-yingyan-ZTJ/git-project01.git

远程打开github仓库的vscode插件 github远程仓库地址_git_11

3)再次查看所有远程仓库地址别名:

远程打开github仓库的vscode插件 github远程仓库地址_远程仓库_12


2.3 推送本地分支到远程仓库

1)基本语法:

git push 别名 分支

提示: 如果没有别名,直接使用远程仓库地址链接

2)案例实操:

git push git-project01 master

GitHub生成Token

远程打开github仓库的vscode插件 github远程仓库地址_github_13

远程打开github仓库的vscode插件 github远程仓库地址_远程仓库_14


远程打开github仓库的vscode插件 github远程仓库地址_github_15


2.4 拉取远程仓库到本地仓库


2.4.1 我们这里先更改一下远程仓库的代码(模仿远程仓库代码和本地不一致的情况)

远程打开github仓库的vscode插件 github远程仓库地址_远程仓库_16


2.4.2 开始拉取远程仓库代码

1)基本语法:

git pull 别名 分支

提示: 如果没有别名,直接使用远程仓库地址链接,我这里使用仓库链接

2)案例实操:

git pull https://github.com/CQUT-yingyan-ZTJ/git-project01.git master

远程打开github仓库的vscode插件 github远程仓库地址_git_17


远程打开github仓库的vscode插件 github远程仓库地址_远程仓库_18


远程打开github仓库的vscode插件 github远程仓库地址_远程仓库_19


2.5 克隆远程仓库到本地

1)基本语法:

git clone 远程地址

2)案例实操:

远程打开github仓库的vscode插件 github远程仓库地址_远程仓库_20

git clone https://github.com/CQUT-yingyan-ZTJ/git-project01.git

远程打开github仓库的vscode插件 github远程仓库地址_github_21

远程打开github仓库的vscode插件 github远程仓库地址_远程仓库_22

现在我们本地也有了远程仓库的代码了

远程打开github仓库的vscode插件 github远程仓库地址_远程仓库_23

3)小结:

小结:clone 会做如下操作。1、拉取代码。2、初始化本地仓库。3、创建别名

远程打开github仓库的vscode插件 github远程仓库地址_远程仓库_24