记一次将本地工程上传到github的过程

记一次将本地工程上传到github的过程

1、首先,进入本地工程所在文件夹,运行git init将工程初始化为git仓库:

[email protected] MINGW64 ~/Desktop/toools/testApiProject
$ git init
Initialized empty Git repository in C:/Users/XH/Desktop/toools/testApiProject/.git/

2、可以运行git status可以查看到此时本地仓库的变化:

[email protected] 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 .将所有的更改提交到暂存区:

[email protected] 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查看,发现,更改已经存入暂存区:

[email protected] 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版本库:

[email protected] 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上新建仓库([email protected]:Sirxy/testApiProject.git)建立连接(即连接到远程仓库):

[email protected] MINGW64 ~/Desktop/toools/testApiProject (master)
$ git remote add origin [email protected]:Sirxy/testApiProject.git

至此,连接工作完成。

7、接着只需要将本地仓库推送(git push -u origin master)到远程github 上:

[email protected] 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)同步到本地仓库,这样远程与本地就一致了:

[email protected] 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(-)

[email protected] MINGW64 ~/Desktop/toools/testApiProject (master)
$

当然,也可以运行git clone [email protected]:Sirxy/testApiProject.git将远程仓库克隆到你的本地也是可以的。

注意:在到达第六步时,需要将自己本地PC的SSH公钥加入到自己的github(参见:版本控制神器——git的基本使用)。
关于生成公钥详细页可以参考git官网:生成 SSH 公钥

转载请备明出处:洪荒少男~

原文地址:https://www.cnblogs.com/sirxy/p/11990777.html

时间: 2024-07-30 13:52:03

记一次将本地工程上传到github的过程的相关文章

将本地工程上传到github

第一步:在github中添加密钥 生成本地密钥: $ ssh-keygen -t rsa -C "[email protected]" 命令执行后会提示生成的.ssh文件夹的位置,进入打开id_rsa.pub文件,复制里面的所有内容. 添加密钥: 回到github,个人头像下进入Settings,再进入SSH,new ssh key,填写title,粘贴复制的密钥. 第二步:本地项目上传: 1.在Project根目录下执行 git init,把工程转化成git工程(工程中增加了.git

详细教程:将本地项目上传到github

作为 一个工程师,将本地项目上传到github进行备份和分享是一个不错的技能,一来可以方便以后的工作,二来可以分享自己的成果.所以下面本人详细教大家如何将本地项目上传到github,十分简单,一学就会!!!! 首先先进入github.网址是:https://github.com/ 如果你还没有在github上注册过账号,那你先要注册一个账号,账号最好是用自己常用的邮箱,方便别人联系你,对你以后的工作极有帮助.下面是刚进入github的页面. 首次要先创建一个仓库,用来存储你的项目.步骤:先用鼠标

如何用命令将本地项目上传到github

一.Git终端软件安装 1.下载windows上git终端,类似shell工具,下载地址:http://msysgit.github.io/ 2.安装方法,打开文件,一路点击Next即可 3.安装完成,界面如下 二.配置 1.打开git bash,输入ssh-keygen -t rsa -C "自己的邮箱地址@XXX.com" ,生成自己的公钥与私钥 2.一路默认回车,会生成公钥.私钥到以下文件夹下id_rsa是私钥,id_rsa.pub是公钥,打开公钥等下要用到 3.浏览器进入自己的

Git的使用--如何将本地项目上传到Github

第一步:我们需要先创建一个本地的版本库(其实也就是一个文件夹). 你可以直接右击新建文件夹,也可以右击打开Git bash命令行窗口通过命令来创建. 现在我通过命令行在桌面新建一个TEST文件夹(你也可以在其他任何地方创建这个文件夹),并且进入这个文件夹 第二步:通过命令git init把这个文件夹变成Git可管理的仓库 这时你会发现TEST里面多了个.git文件夹,它是Git用来跟踪和管理版本库的.如果你看不到,是因为它默认是隐藏文件,那你就需要设置一下让隐藏文件可见. 第三步:这时候你就可以

如何通过TortoiseGit(小乌龟)把本地项目上传到github上

1.第一步: 安装git for windows(链接:https://gitforwindows.org/)一路next就好了, 如果遇到什么问题可以参考我另外一篇文章~^ - ^ 2.第二步:安装小乌龟(我习惯把TortoiseGit叫成小乌龟,所以接下来所有的TortoiseGit我都代替为小乌龟啦) 小乌龟安装步骤(安装完小乌龟之后再安装语言包): 步骤我就不贴出来了,跟git一样一路next就OK了,我把安装需求的安装包贴在下面,可以参考一下~ 别忘记下载中文语言包(看到这里要注意呀 

使用终端命令行将本地项目上传到Github

使用终端命令行将本地项目上传到Github 转自https://blog.csdn.net/fishball1/article/details/52020305 对于IOS开发者来说,Github的使用是必须要掌握的一种技能,而把项目由本地上传到Github有多种方式,1开发工具Xcode配置Git,由Xcode-->Source Control-->Commit:2使用Github客户端上传代码:3使用终端命令行上传到Github.其中我的Github地址有我根据实际项目制作的一个配置说明书

Git的使用--将本地项目上传到Github

1.新建一个项目(文件夹),将要上传的项目放进去: test上传github是我新建的文件夹,es6-Setting-up-the-environment是我要上传的项目: 2.进入D:\test上传github,右键git bush here 3.输入git init 把这个文件夹变成Git可管理的仓库 此时会看到文件夹中多了一个.git文件夹,它是Git用来跟踪和管理版本库的.如果你看不到,是因为它默认是隐藏文件,那你就需要设置一下让隐藏文件可见.且变成了master分支(git bash最

本地项目上传到github新建的空仓库里

很早之前就注册了Github,但对其使用一直懵懵懂懂,很不熟练.直到昨天做完百度前端技术学院的task,想把代码托管到Github上的时候发现自己对于Git的操作是如此之愚钝,所以今天决定把Git好好学习一遍,好让自己以后能更好地使用Github,主要还是通过Git教程 - 廖雪峰的官方网站来学习.简要步骤可以直接看最后的总结. Git的安装就不说了. 第一步:我们需要先创建一个本地的版本库(其实也就是一个文件夹). 你可以直接右击新建文件夹,也可以右击打开Git bash命令行窗口通过命令来创

如何将本地项目上传至GitHub

如何将本地项目上传至GitHub 首先你需要一个github账号,所有还没有的话先去注册吧! https://github.com/ 我们使用git需要先安装git工具,这里给出下载地址,下载后一路直接安装即可: https://git-for-windows.github.io/ 1.进入Github首页,点击New repository新建一个项目  2.填写相应信息后点击create即可 Repository name: 仓库名称 Description(可选): 仓库描述介绍 Publi