一 ,建号 :

1 ,github 是什么 :

  1. 网络仓库。
  2. 我们可以把项目托管在这里。

2 ,网站 :

https://github.com/

3 ,注册账号 :

  1. 登录网址
  2. 按照提示注册
  3. 去邮箱验证,并且创建仓库

4 ,我注册了 2 个账号 : 用来做实验

simayi0808
simayi0909

二 ,github 使用 :( 3-8 可以不管,第 9 步是总结 )

1 ,登录 :

  1. 网址 : https://github.com/
  2. 用户性
  3. 密码

2 ,创建项目 : simayi0808 的登录



githubdesktop切换账户 github可以改用户名吗_git


2.

githubdesktop切换账户 github可以改用户名吗_用户名_02

3 ,simayi0808 把代码扔到网上 :

  1. simayi0808 登录
  2. 创建仓库
  3. 找到远程仓库名字,复制地址 ( https://github.com/simayi0808/simayi01.git )
  4. 指定远程地址,并且给他取一个别名 :
git remote add origin https://github.com/simayi0808/simayi01.git
  1. 上传分支到远程仓库 :
git push origin master
  1. 第一次提示输入用户名和密码 :输入 github 的用户名和密码
  2. 第一次提示输入用户名和密码 :输入 github 的用户名和密码

4 ,遇到问题 :

  1. 问题描述 : Fatal: HttpRequestException encountered.
  2. 问题分析 :
    Github 禁用了TLS v1.0 and v1.1,必须更新Windows的git凭证管理器。
  3. 问题解决 :
    1 ,下载软件 : 百度云盘地址:https://pan.baidu.com/s/1nJkkCyRfxQQE07eWbNJVUw 密码:s9zy)。
    2 ,安装
  4. 退出 git : exit
  5. 重新启动

5 ,查看远程连接列表 :

git remote -v

6 ,重新上传代码 :

  1. 上传分支到远程仓库 :
git push origin master

7 ,移除远程连接 :

git remote rm origin

8 ,遇到问题 :

  1. 问题 : error: failed to push some refs to ‘https://github.com/simayi0808/simayi01.git’
  2. 原因 : 远程库与本地库不一致造成的
  3. 解决 : 先把远程库同步到本地
git pull origin master
  1. 出现这些提示 :
From https://github.com/simayi0808/simayi01
 * [new branch]      master     -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master
  1. 错误原因 : 两个不相干的库,不能合并
  2. 解决 : 强行合并
git pull origin master --allow-unrelated-histories

9 ,探索出一条光滑的马路 : ( 上传代码 )

  1. 指定远程地址,取别名 :
git remote add origin https://github.com/simayi0808/simayi01.git
  1. 远程库与本地库连接 : 强行合并
git pull origin master --allow-unrelated-histories
  1. 上传代码 :
git push origin master

10 ,成功的标志 : 我们的代码上传到 github 了

githubdesktop切换账户 github可以改用户名吗_githubdesktop切换账户_03

三 ,下载代码 : 从网上下载

1 ,去一个目录下 :任意的

githubdesktop切换账户 github可以改用户名吗_githubdesktop切换账户_04

2 ,git 命令行 :

右键 - git bash

3 ,下载项目,并且创建文件夹,将代码放在文件夹中 :

git clone https://github.com/simayi0808/simayi01.git wtt

4 ,切换本地用户名 :

查看当前git用户名: git config user.name
查看当前git邮箱: git config user.email
切换git用户名: git config --global user.name "YOURUSERNAME"
切换git邮箱: git config --global user.email "YOUREMAIL"

5 ,查看全局用户名 :

C:\Users\86182
.gitconfig

四 ,上传代码,上传到网上

1 ,本地仓库创建用户名,邮箱 :

git config user.name “sfl02”

git config user.email “sfl02@163.com”

githubdesktop切换账户 github可以改用户名吗_githubdesktop切换账户_05

2 ,本地仓库,查看当前用户名 :

git config user.name

3 ,本地仓库,查看全局用户名 :

git config --global user.name

4 ,修改代码 :

githubdesktop切换账户 github可以改用户名吗_用户名_06

5 ,提交代码到本地仓库 :

git add bb.txt
git commit

6 ,上传代码到网上 :

git push origin master

7 ,合作伙伴 :

  1. 如果提交不了代码,权限不足。
  2. 原因 : 两个账号没有任何关系。
  3. 我是你的合作伙伴,我就可以向你的里面提交代码了
  4. 我需要你邀请我,成为合作伙伴,才行。