记一次将本地工程上传到github的过程
记一次将本地工程上传到github的过程
1、首先,进入本地工程所在文件夹,运行git init
将工程初始化为git
仓库:
XH@DESKTOP-82MT9LU MINGW64 ~/Desktop/toools/testApiProject
$ git init
Initialized empty Git repository in C:/Users/XH/Desktop/toools/testApiProject/.git/
2、可以运行git status
可以查看到此时本地仓库的变化:
XH@DESKTOP-82MT9LU MINGW64 ~/Desktop/toools/testApiProject (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
.idea/
MyTestPackage/
README.md
__init__.py
nothing added to commit but untracked files present (use "git add" to track)
3、从上面的输出可以看到,此时本地工程仓库的更改并没有存入暂存区。运行git add .
将所有的更改提交到暂存区:
XH@DESKTOP-82MT9LU MINGW64 ~/Desktop/toools/testApiProject (master)
$ git add .
warning: LF will be replaced by CRLF in .idea/workspace.xml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in MyTestPackage/.idea/workspace.xml.
The file will have its original line endings in your working directory
4、接着,运行git status
查看,发现,更改已经存入暂存区:
XH@DESKTOP-82MT9LU MINGW64 ~/Desktop/toools/testApiProject (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: .idea/TestSB.iml
new file: .idea/misc.xml
new file: .idea/modules.xml
new file: .idea/workspace.xml
new file: MyTestPackage/.idea/MyTestPackage.iml
new file: MyTestPackage/.idea/misc.xml
new file: MyTestPackage/.idea/modules.xml
new file: MyTestPackage/.idea/workspace.xml
new file: MyTestPackage/A.py
new file: MyTestPackage/B.py
new file: MyTestPackage/__init__.py
new file: MyTestPackage/__pycache__/A.cpython-37.pyc
new file: MyTestPackage/__pycache__/__init__.cpython-37.pyc
new file: MyTestPackage/__pycache__/send_requests.cpython-37.pyc
new file: MyTestPackage/measurement.py
new file: MyTestPackage/send_requests.py
new file: README.md
new file: __init__.py
5、然后,运行git commit -m "first commit"
将本地工程仓库刚才存入暂存区的更改提交到git版本库:
XH@DESKTOP-82MT9LU MINGW64 ~/Desktop/toools/testApiProject (master)
$ git commit -m "first commit"
[master (root-commit) 06272ba] first commit
18 files changed, 1040 insertions(+)
create mode 100644 .idea/TestSB.iml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/workspace.xml
create mode 100644 MyTestPackage/.idea/MyTestPackage.iml
create mode 100644 MyTestPackage/.idea/misc.xml
create mode 100644 MyTestPackage/.idea/modules.xml
create mode 100644 MyTestPackage/.idea/workspace.xml
create mode 100644 MyTestPackage/A.py
create mode 100644 MyTestPackage/B.py
create mode 100644 MyTestPackage/__init__.py
create mode 100644 MyTestPackage/__pycache__/A.cpython-37.pyc
create mode 100644 MyTestPackage/__pycache__/__init__.cpython-37.pyc
create mode 100644 MyTestPackage/__pycache__/send_requests.cpython-37.pyc
create mode 100644 MyTestPackage/measurement.py
create mode 100644 MyTestPackage/send_requests.py
create mode 100644 README.md
create mode 100644 __init__.py
到这里,工程已经变成了git版本库了。
6、然后,需要将本地仓库与github上新建仓库(git@github.com:Sirxy/testApiProject.git)建立连接(即连接到远程仓库):
XH@DESKTOP-82MT9LU MINGW64 ~/Desktop/toools/testApiProject (master)
$ git remote add origin git@github.com:Sirxy/testApiProject.git
至此,连接工作完成。
7、接着只需要将本地仓库推送(git push -u origin master
)到远程github 上:
XH@DESKTOP-82MT9LU MINGW64 ~/Desktop/toools/testApiProject (master)
$ git push -u origin master
Enumerating objects: 21, done.
Counting objects: 100% (21/21), done.
Delta compression using up to 4 threads
Compressing objects: 100% (18/18), done.
Writing objects: 100% (21/21), 9.46 KiB | 569.00 KiB/s, done.
Total 21 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), done.
To github.com:Sirxy/testApiProject.git
* [new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
8、如果,在github上直接更改了你的代码,注意:一定要将远程仓库拉下来(在本地工程目录下运行git pull
)同步到本地仓库,这样远程与本地就一致了:
XH@DESKTOP-82MT9LU MINGW64 ~/Desktop/toools/testApiProject (master)
$ git pull
remote: Enumerating objects: 12, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 8 (delta 6), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (8/8), done.
From github.com:Sirxy/testApiProject
06272ba..1ce9e08 master -> origin/master
Updating 06272ba..1ce9e08
Fast-forward
MyTestPackage/measurement.py | 6 +++---
MyTestPackage/send_requests.py | 10 +++++-----
2 files changed, 8 insertions(+), 8 deletions(-)
XH@DESKTOP-82MT9LU MINGW64 ~/Desktop/toools/testApiProject (master)
$
当然,也可以运行git clone git@github.com:Sirxy/testApiProject.git
将远程仓库克隆到你的本地也是可以的。
注意:在到达第六步时,需要将自己本地PC的SSH公钥加入到自己的github(参见:版本控制神器——git的基本使用)。
关于生成公钥详细页可以参考git官网:生成 SSH 公钥
转载请备明出处:记一次将本地工程上传到github的过程
记一次将本地工程上传到github的过程的更多相关文章
- Git随笔:尝试将本地工程上传至Github上的repository仓库,构建远端与本地协同的Git环境
上传工程至自己的Github公开库,步骤如下: 第1步:建立本地 git 仓库,cd 到你的本地项目根目录下,执行 git init 命令: 第2步:将本地项目工作区的所有文件添加到暂存区.小数点 & ...
- 本地项目上传至GitHub
本地项目上传至GitHub 使用git上传 一.安装git 直接官网下载,安装即可. git官网下载 github下载 按照好后大概就是这个样子 二.创建公钥和私钥 有的就可跳过此步骤 我们双击打开g ...
- 将本地项目上传到Github
将本地项目上传到Github 转载请注明出自天外归云的博客. 前提 已经下载了Git到本地. 创建Repository 首先登陆我的Github页面,在Repositories中New一个并起Repo ...
- 详细教程:将本地项目上传到github
作为 一个工程师,将本地项目上传到github进行备份和分享是一个不错的技能,一来可以方便以后的工作,二来可以分享自己的成果.所以下面本人详细教大家如何将本地项目上传到github,十分简单,一学就会 ...
- Git的使用-如何将本地项目上传到Github
默认你的电脑上已经安装了git. 第一步:我们需要先创建一个本地的版本库(其实也就是一个文件夹). 你可以直接右击新建文件夹,也可以右击打开Git bash命令行窗口通过命令来创建. 现在我通过命令行 ...
- 如何用命令将本地项目上传到github
一.Git终端软件安装 1.下载windows上git终端,类似shell工具,下载地址:http://msysgit.github.io/ 2.安装方法,打开文件,一路点击Next即可 3.安装完成 ...
- 使用 vscode将本地项目上传到github以及删除github上的某个文件夹
安装Git后,可以看到windows环境下有两个命令输入窗口Git CMD 和Git Bash Git GUI是可视化图形界面 Git中的Bash是基于CMD的,在CMD的基础上增添一些新的命令与功能 ...
- 如何通过TortoiseGit(小乌龟)把本地项目上传到github上
1.第一步: 安装git for windows(链接:https://gitforwindows.org/)一路next就好了, 如果遇到什么问题可以参考我另外一篇文章~^ - ^ 2.第二步:安装 ...
- Git的使用--如何将本地项目上传到Github(三种简单、方便的方法)
一.第一种方法: 1.首先你需要一个github账号,所以还没有的话先去注册吧! https://github.com/ 我们使用git需要先安装git工具,这里给出下载地址,下载后一路(傻瓜式安装) ...
随机推荐
- 阿里云和微软共同开源的 OAM 对 Kubernetes 开发人员意味着什么?
上周,微软和阿里巴巴共同推出了开放应用模型(OAM),用于定义部署在任何地方的应用模型的一种规范.Rudr是Microsoft基于Kubernetes环境的OAM标准实现. 我用了一个周末来了解OAM ...
- 第八篇 Flask中的蓝图
随着业务代码的增加,将所有代码都放在单个程序文件中,是非常不合适的.这不仅会让代码阅读变得困难,而且会给后期维护带来麻烦.如下示例:我们在一个文件中写入多个路由,这会使代码维护变得困难. 如图所示,如 ...
- day4-01 流程控制
目录 一.if语法 1.什么是if? 2.语法结构 2.1.if 条件: 2.2.if...else: 2.3.if...elif...else: 2.4.if嵌套 二.循环结构 2.1 什么是循环结 ...
- 前端技术之:JavaScript Test 断言库
expect 声称可以写更好的断言. https://github.com/mjackson/expect chai 可以写BDD样式的断言,也可以写TDD样式的断言,可用于Node.js与浏览器 ...
- Kruskal算法求最小生成树 笔记与思路整理
整理一下前一段时间的最小生成树的算法.(其实是刚弄明白 Kruskal其实算是一种贪心算法.先将边按权值排序,每次选一条没选过的权值最小边加入树,若加入后成环就跳过. 先贴张图做个示例. (可视化均来 ...
- Kong04- Kong 四大参考说明
Kong 四大参考说明 Kong 的官方有很多详细的参考说明,比如配置文件.命令行.Admin API.代理.负载均衡,接下来我们简单看一下,都提供什么内容. 本文主要基于 Kong 1.3 版本进行 ...
- 前端组件用 Scope 发布 npm 包的方法
1.引言 多人.多组织或多组件发布 npm 包到同一个仓库时,可能出现命名冲突问题. 为了解决这个问题,npm 引入了“scope”(范围)概念. 在 Angular 项目中,我们通常可以看到“@an ...
- C函数库errno.h概况
在linux中使用c语言编程时,errno是个很有用的动动.他可以把最后一次调用c的方法的错误代码保留.但是如果最后一次成功的调用c的方法,errno不会改变.因此,只有在c语言函数返回值异常时,再检 ...
- [UWP]使用SpringAnimation创建有趣的动画
1. 什么是自然动画 最近用弹簧动画(SpringAnimation)做了两个番茄钟,关于弹簧动画官方文档已经介绍得够详细了,这篇文章就摘录一些官方文档核心内容. 在传统UI中,关键帧动画(KeyFr ...
- Spring Boot 2.x监控数据可视化(Actuator + Prometheus + Grafana手把手)
TIPS 本文基于Spring Boot 2.1.4,理论支持Spring Boot 2.x所有版本 众所周知,Spring Boot有个子项目Spring Boot Actuator,它为应用提供了 ...