mc02_配置本地git仓库并上传到github
注册github账号
仔细阅读使用说明便可,这里提一下如何删除一个repository。
点击要删除的repository,打开后点击Settings

然后滚动到页面最下方,点击最后一个按钮


在弹出框中再次输入repository的名称,确认后删除
创建一个reposition

创建后有以下提示,下面在安装git后按提示操作
…or create a new repository on the command line
echo "# dao" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/tanpf/dao.git
git push -u origin master
下载git软件并安装
这里使用的是Git-2.14.1-64-bit,在windows上下一步下一步即可

git bash,它把windows上的操作转化为linux shell类似的操作,通过在里面执行一些命令来实现git的功能。

比如,进入G:\all\code\git目录并创建javafx目录

配置全局邮件与名称
cd /d/code/git
mkdir dao
cd dao
git config --global user.email "automng@aliyun.com"
git config --global user.name "tanpf"
若添加后则可以替换
git config --global --replace-all user.email "automng@aliyun.com"
git config --global --replace-all user.name "tanpf"
邮箱与名称可以自定义。
进入创建的目录,准备以该目录为根目录同步github
cd /d/code/git/dao
创建一个文件,github建议目录下放的说明文件
echo "# dao" >> README.md
将该目录初始化为一个git仓库目录
git init
将README.md文件添加到仓库
git add README.md
写一句文字说明并提交本次添加的文件到本地仓库,m 就是message
git commit -m "first commit"
在远程github与本地仓库间建立联系,以后“origin”在本地git仓库中就表示https://github.com/tanpf/dao.git这个远程服务器或者远程主机了
git remote add origin https://github.com/tanpf/dao.git
将新提交到本地仓库的文件推送到github origin的master分支,github默认第一个分支的名称为master
git push -u origin master
该步骤会提示连接github所需要的用户名与密码,输入即可。再次查看github上,文件已经传送完成。
配置SSH为传输的内容加密
执行以下命令并输入三次回车(邮箱名称可自定义)
ssh-keygen -t rsa -C "automng@aliyun.com"

在github上添加本地ssh公钥

SSH and GPG keys --> New SSH key
cat id_rsa.pub 将 id_rsa.pub的内容添加到key中
cd /d/code/git/dao
cp -r /d/wkspace/workspaces/javafx/ppcore/ .
git add .
git status
git commit -m "ppcore first commit"
git push origin master
这是第二次提交,push没有加-u
文件删除
删除本地文件
cd /d/code/git/dao
rm -rf ppcore/
git commit -m "rm ppcore"
从本地git仓库删除
git rm -rf ppcore/
git commit -m "rm ppcore"
从github分支上删除该文件
git add .
git commit -m "rm ppcore"
git push origin master
添加删除文件示例
$ cp -r /d/code/dao/pplib/ .
$ git add .
$ git commit -m "add pplib"
$ git push origin master #推送到远程origin主机的master分支
至此,本地、本地git仓库,远程github上都有了pplib文件 $ ll
total 1
drwxr-xr-x 1 Administrator 197121 0 7月 22 12:13 pplib/
-rw-r--r-- 1 Administrator 197121 6 7月 21 22:39 README.md
$ rm -rf pplib/
$ ll
total 1
-rw-r--r-- 1 Administrator 197121 6 7月 21 22:39 README.md
$ git checkout -- pplib
$ ll
total 1
drwxr-xr-x 1 Administrator 197121 0 7月 22 12:17 pplib/
-rw-r--r-- 1 Administrator 197121 6 7月 21 22:39 README.md $ git rm -rf pplib/
rm 'pplib/mysql/mysql-connector-java-5.0.4-bin.jar'
rm 'pplib/pplib.iml'
$ ll
total 1
-rw-r--r-- 1 Administrator 197121 6 7月 21 22:39 README.md
$ git commit -m "rm pplib from git"
[master 2765db8] rm pplib from git
2 files changed, 11 deletions(-)
delete mode 100644 pplib/mysql/mysql-connector-java-5.0.4-bin.jar
delete mode 100644 pplib/pplib.iml #从本地仓库中删除后无法checkout回来了
$ git checkout -- pplib
error: pathspec 'pplib' did not match any file(s) known to git.
$ ll
total 1
-rw-r--r-- 1 Administrator 197121 6 7月 21 22:39 README.md #由于github上文件还在,还可以从github上拉下来
$ git checkout origin/master pplib
$ ll
total 1
drwxr-xr-x 1 Administrator 197121 0 7月 22 12:43 pplib/
-rw-r--r-- 1 Administrator 197121 6 7月 21 22:39 README.md
mc02_配置本地git仓库并上传到github的更多相关文章
- (超详细)使用git命令行将本地仓库代码上传到github或gitlab远程仓库
(超详细)使用git命令行将本地仓库代码上传到github或gitlab远程仓库 本地创建了一个 xcode 工程项目,现通过 命令行 将该项目上传到 github 或者 gitlab 远程仓库,具体 ...
- 使用git将项目上传到github
使用git将项目上传到github(最简单方法) 首先你需要一个github账号,所有还没有的话先去注册吧! https://github.com/ 我们使用git需要先安装git工具,这里给出下 ...
- 只操作git(cmd)就可以使用git将项目上传到github
代码改变世界 使用git将项目上传到github(最简单方法) 首先你需要一个github账号,所有还没有的话先去注册吧! https://github.com/ 我们使用git需要先安装git工具, ...
- 使用git将代码上传到GitHub
使用git将代码上传到GitHub 结束了前一段的时间的杂七杂八的生活,最近又快开始动一动已经吃了好长时间土的GitHub,以前的git指令基本上忘个差不多,现在记录一下,利用git将代码上传. ...
- 使用Git将本地项目或代码上传到GitHub上
1.要托管到github,那你就应该要有一个属于你自己的github帐号,所以你应该先到github.com注册.打开浏览器在地址栏输入地址:github.com 填写用户名.邮箱.密码,点击Sign ...
- 使用Git将本地代码上传到GitHub
#1注册GitHub账号 *1)到https://github.com/注册GitHub账号 #2在GitHub上建立GitHub仓库 *1)登录后点击右下方的"new repository ...
- 如何用git把本地代码上传到github
注册账户以及创建仓库 要想使用github第一步当然是注册github账号了.之后就可以创建仓库了(免费用户只能建公共仓库),Create a New Repository,填好名称后Create,之 ...
- git基本操作:使用git将本地代码上传到GitHub
一.创建github repository(仓库) 1.登录GitHub 创建GitHub仓库,首先需要登录GitHub,GitHub网址:https://github.com.如果没有GitHub账 ...
- 利用git将项目上传到github
本文主要介绍如果用git将项目上传到githup. 一.准备工作 (1)欲将项目上传到githup,先在githup上新建一个仓库.这里就不介绍. (2 ...
随机推荐
- C++面向对象类的实例题目二
题目描述: 编写一个程序,设计一个产品类Product,其定义如下: class Product { public: Product(char *n,int p,int q); //构造函数 ~Pro ...
- 【转】pecl,pear的不同
PEAR是PHP扩展与应用库(the PHP Extension and Application Repository)的缩写.它是一个PHP扩展及应用的一个代码仓库,基于php代码的,安装目录在/u ...
- PCL—关键点检测(NARF)低层次点云处理
博客转载自:http://www.cnblogs.com/ironstark/p/5051533.html 关键点检测本质上来说,并不是一个独立的部分,它往往和特征描述联系在一起,再将特征描述和识别. ...
- c# 新中新二代身份证阅读,包含头像,支持华视
需要用到dll和文件: 其中3个dll文件是需要调用的dll,license.dat文件为解压图片的授权文件 以下是需要用到的dll里面的方法: /************************端口 ...
- Qt嵌入式开发环境搭建
一.Qt版本介绍 按照不同的图形界面来划分,分为四个版本: 1.Win32版:适用于windows平台 2.X11版:适用于各种X系统的Linux和Unix平台 3.Mac版:适用于苹果的MacOS ...
- CF 464E The Classic Problem
补一补之前听课时候的题. 考虑使用dij算法求最短路,因为边权存不下,所以考虑用主席树维护二进制位,因为每一次都只会在一个位置进行修改,所以可以暴力进位,这样均摊复杂度是对的. <算法导论> ...
- C++面试笔记--单链表
1.编程实现单链表删除节点. 解析:如果删除的是头节点,如下图: 则把head指针指向头节点的下一个节点.同时free p1,如下图所示: 如果删除的是中间节点,如下图所示: 则用p2的n ...
- HttpGet和HttpPost处理重定向的区别
get方法默认会处理302的重定向,response获取到的页面其实是重定向以后的页面,通过response.getStatusLine(),取到的值是200. 通过设置可以用post方法去请求或者把 ...
- jQuery的选择器+实例
返回目录 jQuery的冒号选择器 表单 :input :text :password :radio :checkbox :submit :image :reset :button :file :h ...
- 「JOI 2017 Final」JOIOI 王国
「JOI 2017 Final」JOIOI 王国 题目描述 题目译自 JOI 2017 Final T3「 JOIOI 王国 / The Kingdom of JOIOI」 JOIOI 王国是一个 H ...