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 ...
随机推荐
- cocos2d-js 骨骼动画 3.10
近期使用了cocos动画中的骨骼动画,这里记录使用的两种方式(3.10版): 一.cocos自带的动画编辑器导出的动画 ccs.armatureDataManager.addArmatureFileI ...
- python3-file的修改实现类似shell中sed的功能
# Auther: Aaron Fan '''思路:目的是为了修改yesterday这个文件,但是因为无法直接去修改这个文件,所以需要先把修改好的内容写入高yesterday.new这个文件中,然后再 ...
- ipa包使用命令上传fir.im或者蒲公英
我们的工程做了自动打包处理,但是每次打完ipa后只是放置于一个共享盘或者本地,为了方便测试,每次都要手动上传上传fir或者蒲公英,比较麻烦.所以研究了一下怎么能在打完包后直接脚本上传到上传fir或者蒲 ...
- 搭建邮件服务器 Postfix + Dovecot (CentOS)
最近分配到一台ECS服务器,需要搭建一台邮件服务器. 查了一波资料选择了Postfix (smtp)和 Dovecot(pop3). 推荐教程:http://www.cnblogs.com/zlbei ...
- c# 创建XML文档,解析XML文档
1.静态函数 using System; using System.Collections.Generic; using System.Linq; using System.Text; using S ...
- .NET 图片上传接收类
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- 编译原理-First集和Follow集
刚学first集和follow集的时候,如果上课老师没有讲明白或者自己没听明白,自己看的时候还真是有点难理解,不过结合着具体的题目可以理解的更快. 先看一下两种集合的求法: First集合的求法: ...
- Linux基础学习(二)
前言: 我们在上一节了解了一下linux的硬件组成,虽然也许对具体的东西还不甚了解,但是我们知道了linux下一切皆文件这一特性 我们装好了CentOS7的虚拟机(这个可以看别人教程来装起来,比较简单 ...
- 前端JS AES加密 后端PHP AES加解密
<!DOCTYPEhtml> <html> <head> <title>aes demo</title> </head> < ...
- UVA11270 Tiling Dominoes
\(\color{#0066ff}{ 题目描述 }\) 给定一个m×n的矩形网格,用1×2多米诺骨牌完全平铺. 请注意,即使一个平铺的旋转与另一个平铺相匹配,它们仍算作不同的平铺. 下面显示了一个平铺 ...