使用git服务上传文件到github仓库

一、git下载与安装

1、在git官网上下载自己电脑的版本
使用git服务上传文件到github仓库
2、下载好,一路next,安装
3、安装好后在桌面界面空白处点击鼠标右键,会出现如下界面
使用git服务上传文件到github仓库
安装完成

二、使用

1、 在github上申请一个账户。

git GUI here可视化操作

1、建立连接

鼠标右键单击git gui here,在Help->Show SSH Key中
使用git服务上传文件到github仓库
点击Generate Key,生成**。
使用git服务上传文件到github仓库
github设置
点击new SSH keys添加一个key
title随意输入仅仅作为标识来区别。
Key将之前的**粘贴上去。

2、初始化git仓库

点击Create New Repositor,选择需要上传的文件位置,点击Create
使用git服务上传文件到github仓库

3、保存在本地git中

如果Unstaged Changes(未缓存的改动)中包含文件,则先点击Stage Changed,将未缓存的改动加入缓存。
再点击Commit;否则需要先点击Rescan扫描项目中进行过改动的文件。注:(Initial Commit message)提交描述必须要填写,不然无法提交。

提交成功后,我们可以在Repository->Visualize All Branches History中看到我们提交的历史记录(这是提交到本地而不是提交到远程服务器)。至此,本地版本库就创建成功了。

4、 提交到github上

在Git Gui中,选择Remote->add添加远程服务器,远程服务器信息有两种填写方式,填写https地址或ssh地址,对应github项目的https和ssh地址,推荐使用ssh方式。

Name随意输入仅仅作为本地标识来区别。
在github建立的仓库点击code,选择ssh,复制到Location中。
使用git服务上传文件到github仓库
使用git服务上传文件到github仓库
点击push提交至远程客户端。

5、 同步github上代码到本地

git 获取远程分支内容,本地合并
Remote–>Fetch from -->名字
使用git服务上传文件到github仓库

6、更改分支推送

Branch->Create…
使用git服务上传文件到github仓库
使用git服务上传文件到github仓库
name新分支的名字

点击create确认
点击push推送。

7、合并分支

点击进入Comparing changes界面,合并分支。
或者在Comparing changes中,合并分支。
使用git服务上传文件到github仓库
可以合并的分支(更改前的必须一样才能合并)
使用git服务上传文件到github仓库
点击合并
使用git服务上传文件到github仓库
确认合并
使用git服务上传文件到github仓库

8、保护master分支

使用git服务上传文件到github仓库
选择这个可以保护master不被强制推送而改变
使用git服务上传文件到github仓库
可以推送到除了保护的分支之外的其他所有分支。

三、不同系统之间使用

1、Ubuntu

1、安装GIT

sudo apt-get install git

2、安装git界面

sudo apt-get install git-gui

3、启动git gui界面

git gui

git Bash Here

1、 设置
在想要上传的文件夹下单击鼠标右键中的git bush here进入命令行操作。
1.用户名

git config --global user.name “自己的用户名”

2.配置邮箱

git config --global user.email “申请账户时的邮箱”

以后再补。