注册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的更多相关文章

  1. (超详细)使用git命令行将本地仓库代码上传到github或gitlab远程仓库

    (超详细)使用git命令行将本地仓库代码上传到github或gitlab远程仓库 本地创建了一个 xcode 工程项目,现通过 命令行 将该项目上传到 github 或者 gitlab 远程仓库,具体 ...

  2. 使用git将项目上传到github

    使用git将项目上传到github(最简单方法)   首先你需要一个github账号,所有还没有的话先去注册吧! https://github.com/ 我们使用git需要先安装git工具,这里给出下 ...

  3. 只操作git(cmd)就可以使用git将项目上传到github

    代码改变世界 使用git将项目上传到github(最简单方法) 首先你需要一个github账号,所有还没有的话先去注册吧! https://github.com/ 我们使用git需要先安装git工具, ...

  4. 使用git将代码上传到GitHub

    使用git将代码上传到GitHub   结束了前一段的时间的杂七杂八的生活,最近又快开始动一动已经吃了好长时间土的GitHub,以前的git指令基本上忘个差不多,现在记录一下,利用git将代码上传. ...

  5. 使用Git将本地项目或代码上传到GitHub上

    1.要托管到github,那你就应该要有一个属于你自己的github帐号,所以你应该先到github.com注册.打开浏览器在地址栏输入地址:github.com 填写用户名.邮箱.密码,点击Sign ...

  6. 使用Git将本地代码上传到GitHub

    #1注册GitHub账号 *1)到https://github.com/注册GitHub账号 #2在GitHub上建立GitHub仓库 *1)登录后点击右下方的"new repository ...

  7. 如何用git把本地代码上传到github

    注册账户以及创建仓库 要想使用github第一步当然是注册github账号了.之后就可以创建仓库了(免费用户只能建公共仓库),Create a New Repository,填好名称后Create,之 ...

  8. git基本操作:使用git将本地代码上传到GitHub

    一.创建github repository(仓库) 1.登录GitHub 创建GitHub仓库,首先需要登录GitHub,GitHub网址:https://github.com.如果没有GitHub账 ...

  9. 利用git将项目上传到github

            本文主要介绍如果用git将项目上传到githup. 一.准备工作         (1)欲将项目上传到githup,先在githup上新建一个仓库.这里就不介绍.         (2 ...

随机推荐

  1. aspose ppt转图片

    如果直接转图片,会很模糊采用先将ppt转pdf,在通过pdf转图片,这样出来的结果就非常清晰 var pptFileName = "公司网络及计算机使用与要求.pptx"; Pre ...

  2. 算法Sedgewick第四版-第1章基础-2.1Elementary Sortss-003比较算法及算法的可视化

    一.介绍 1. 2. 二.代码 1. package algorithms.elementary21; /*********************************************** ...

  3. NDIS中间层驱动实现截获数据包、包过滤功能

    1.包截获功能 http://wenku.baidu.com/view/43960751f01dc281e53af055.html 2.包过滤功能 http://wenku.baidu.com/lin ...

  4. Luogu 4151 [WC2011]最大XOR和路径

    你谷又乱评分…… 首先发现答案只有可能是从$1$开始走到$n$,中间绕若干个环,然后使它取到的异或值最大. 这样子的话我们可以随便先取一条路径,强制选择走这条路径,然后把所有的环都丢进线性基里面去,因 ...

  5. SDUT 2498 AOE网上的关键路径

    AOE网上的关键路径 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 一个无环的有向图称为无 ...

  6. C# 实现文件(夹)在ftp服务器间的同步【无需将文件(夹)保存到本地】

    C#实现不同ftp服务器间文件(夹)同步 图1 实现不同ftp服务器间文件(夹)同步的实现思路图 /// <summary> /// 将文件夹1从ftp服务器1移到ftp服务器2文件夹2 ...

  7. 数据结构_bubble_sort

    问题描述 给定一个 1~N 的排列 P,即 1 到 N 中的每个数在 P 都只出现一次. 现在要对排列 P 进行冒泡排序,代码如下:for (int i = 1; i <= N; ++i)for ...

  8. Business Trip to Taian

    工作必备 电脑.电源(下载好小助手.VPN.个人证书) 手机.充电器 重要参考书籍 生活用品 衣服,夏天体恤为主,别忘了加件外套 被罩.床单和枕巾 牙刷牙膏肥皂之类的必带,中号浴巾一条 拖鞋要不要? ...

  9. Visual Studio 2012自动添加注释(如版权信息等)

    http://blog.csdn.net/jiejiaozhufu/article/details/16357721注释宏的原码 /********************************** ...

  10. SQL SERVER 提供了一些时间函数:

    SQL SERVER 提供了一些时间函数:取当前时间:select getdate()取前一个月的时间:SELECT DATEADD(MONTH,-1,GETDATE()) 月份减一个月取年份:SEL ...