fetch整个仓库 github_开发环境-Git仓库

本文提供Git教程资源,介绍了Git的基本概念、安装、基础命令、分支策略及远程仓库管理。详细讲解了如何在GitHub和Gitee创建仓库,以及配置多个SSH密匙以连接不同远程仓库。
摘要由CSDN通过智能技术生成

Git教程资源

以下Git教程内容均转载自Git 教程_w3cschool和Git 教程 | 菜鸟教程


Git简介

Git 是一个开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目。

e7f3f9173e15efcda6f1487ea3b2bcc9.png

安装Git

安装包下载地址:https://gitforwindows.org/

b2ffb7698e55a71c894c8c41cc79cdc4.png

Git的基本概念

  • 工作区:就是你在电脑里能看到的目录。
  • 暂存区:英文叫stage, 或index。一般存放在"git目录"下的index文件(.git/index)中,所以我们把暂存区有时也叫作索引(index)。
  • 版本库:工作区有一个隐藏目录.git,这个不算工作区,而是Git的版本库。

下面这个图展示了工作区、版本库中的暂存区和版本库之间的关系:

c1877d469d0c175e80535ce22de1aa38.png

Git的基础命令

34ac4d6c10c1c6c3ba90dba699c37cda.png

Git分支策略

e003bd52e0c2a0a4e2dc9accc2c7715b.png

Git的远程仓库

Github和Gitee


创建平台的Git仓库

RiceQuant 米筐

1. 建立本地仓库

创建项目路径,D:QuantLibProjectsRiceQuant,在路径先下创建仓库

#在项目路径下
$ pwd
/d/QuantLib/Projects/RiceQuant
#创建仓库
$ git init
Initialized empty Git repository in D:/QuantLib/Projects/RiceQuant/.git/
#查看状态
$ git status
On branch master

No commits yet

nothing to commit (create/copy files and use "git add" to track)

2. 编辑提交文件

新建一个文本文件helloworld.py提交

#创建文件
$ touch helloworld.py
$ echo "print('hello wolrd')" > helloworld.py
$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        helloworld.py

nothing added to commit but untracked files present (use "git add" to track)
#加入缓存
$ git add helloworld.py
$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   helloworld.py
#提交缓存
$ git commit -am 'hello world'
[master (root-commit) 3a9c483] hello world
 1 file changed, 1 insertion(+)
 create mode 100644 helloworld.py
#最后查看状态
$ git status
On branch master
nothing to commit, working tree clean

3. 连接远程仓库

GitHub

GitHub注册后,新建一个仓库,在用设置里填入SSH密匙。在本地Git中添加远程仓库,推送修改后文件

#添加远程目录
$ git remote add github git@github.com:qt-aaron/RiceQuant.git
$ git remote -v
github  git@github.com:qt-aaron/RiceQuant.git (fetch)
github  git@github.com:qt-aaron/RiceQuant.git (push)
$ git push -u github master
Everything up-to-date
Branch 'master' set up to track remote branch 'master' from 'github'.
#修改文件
$ echo "#this is a test!" >> helloworld.py
$ git status
On branch master
Your branch is up to date with 'github/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   helloworld.py

no changes added to commit (use "git add" and/or "git commit -a")
#提交文件
$ git commit -am 'a test message.'
warning: LF will be replaced by CRLF in helloworld.py.
The file will have its original line endings in your working directory
[master 8f43d4e] a test message.
 1 file changed, 1 insertion(+)
#推送文件
$ git push github
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 269 bytes | 269.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To github.com:qt-aaron/RiceQuant.git
   3a9c483..8f43d4e  master -> master

ef1ef7a653e5cb64a846a3c778725493.png

Gitee

gitee的页面和github极其相似,配置流程基本一致。

配置多个SSH密匙

如果各远程仓库之间用的ssh密匙不一致,需要在~/.ssh文件夹下增加config文件进行配置。

7a5e43769a8522a8136733329e30b7a9.png
# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_gitee
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github

Uqer 优矿

完全和RiceQuant类似。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值