当前位置: 首页 > news >正文

林州网站建设服务磁力天堂最佳搜索引擎入口

林州网站建设服务,磁力天堂最佳搜索引擎入口,网站要和别人做api 链接,营销型企业网站的含义Git基础之远程服务器 Author:onceday date:2023年3月5日 满满长路有人对你微笑过嘛… windows安装可参考文章:git简易配置_onceday_CSDN博客 參考文档: 《progit2.pdf》,Progit2 Github。《git-book.pdf》 文章目…

Git基础之远程服务器

Author:onceday date:2023年3月5日

满满长路有人对你微笑过嘛…

windows安装可参考文章:git简易配置_onceday_CSDN博客

參考文档:

  • 《progit2.pdf》,Progit2 Github。
  • 《git-book.pdf》

文章目录

      • Git基础之远程服务器
        • 1.概述
        • 2. 创建裸仓库
        • 3. Git 守护进程
        • 4. HTTP协议

1.概述

远程仓库可以是一个裸仓库(base repository),即一个没有当前工作目录的仓库,只包含.git文件夹里面的内容。

可以通过四种协议来传输资料:

  • 本地协议Local,远程库是同一主机上的另外一个目录,通常通过共享文件系统实现。如果将所有代码都存放于同一台电脑,不是一个好主意。可以使用/srv/git/my.gitfile:///srv/git/mygit,如果没有指定file://,Git会尝试使用硬链接(hard link)或直接赋值所需的文件,如果指定file://,Git会触发平时用于网路传输资料的进程,效率可能会低一些。

    如下是一个示例:

    git clone /home/ubuntu/c-code/.git
    git add local /home/ubuntu/c-code/.git
    
  • HTTP协议,有智能协议(可以根据需要提供匿名服务或者加密授权服务)和哑协议两种(web服务器提供静态服务)。

  • SSH(secure Shell)协议,常见的安全和加密传输协议。

  • Git协议,这是包含在Git里的一个特殊守护进程,不能提供授权和加密服务,传输速率快。

一般来说HTTP协议和Git协议可用于大型开源代码的分享服务器,如果是可控开发,还是需要用到HTTPS协议和SSH协议。

2. 创建裸仓库

Git仓库需要创建裸仓库,通常需要从现有仓库中导出,裸仓库不能包含当前工作目录。

ubuntu->git-test:$ git clone --bare cc cc.git
Cloning into bare repository 'cc.git'...
done.
ubuntu->git-test:$ ll cc.git/
total 44
drwxrwxr-x  7 ubuntu ubuntu 4096 Mar  5 13:07 ./
drwxrwxr-x  4 ubuntu ubuntu 4096 Mar  5 13:07 ../
drwxrwxr-x  2 ubuntu ubuntu 4096 Mar  5 13:07 branches/
-rw-rw-r--  1 ubuntu ubuntu  116 Mar  5 13:07 config
-rw-rw-r--  1 ubuntu ubuntu   73 Mar  5 13:07 description
......
ubuntu->git-test:$ ll cc
total 112
drwxrwxr-x 3 ubuntu ubuntu  4096 Mar  5 12:51 ./
drwxrwxr-x 4 ubuntu ubuntu  4096 Mar  5 13:07 ../
-rw-rw-r-- 1 ubuntu ubuntu  8124 Mar  5 12:48 .clang-format
drwxrwxr-x 8 ubuntu ubuntu  4096 Mar  5 12:48 .git/
-rw-rw-r-- 1 ubuntu ubuntu     6 Mar  5 12:48 .gitignore
-rw-rw-r-- 1 ubuntu ubuntu    63 Mar  5 12:48 makefile
-rw-rw-r-- 1 ubuntu ubuntu   408 Mar  5 12:48 socket.c
......

如上所示,使用git clone --bare project project.git即可,project是当前git仓库的目录路径,project.git是新的裸仓库的目录路径。注意project.git是目录不是文件,后缀.git是惯例使用,而非必须

上述命令的效果和cp -Rf project/.git project.git是基本等价的,但配置文件有些许不同。

可以看到,裸仓库中只有.git中的文件,而没有当前工作目录的内容

创建好仓库后,可以通过SSH协议把文件复制到服务器上(需要先将SSH公钥放在服务器上):

scp -r cc.git ubuntu@onceday.work:/home/ubuntu/git-test/

然后便可以使用ssh来读取此服务器上/home/ubuntu/git-test/目录来克隆对应仓库。

git clone ubuntu@onceday.work:/home/ubuntu/git-test/cc.git

如果SSH连接用户对该目录拥有可写入权限,那么他就拥有推送权限

使用SSH连接直接初始化git裸仓库的命令如下:

git init --bare --shared

对于小型项目,上面的SSH+裸仓库已够用,只需通过对不同成员的账号进行管理即可。

对于用于ssh连接的账户,其shell可以设置为git-shell,可以方便地将用户git的活动限制在与Git相关的范围内。更换ssh连接使用下述命令即可:

$ cat /etc/shells 		# see if git-shell is already in there. If not...
$ which git-shell 		# make sure git-shell is installed on your system.
$ sudo -e /etc/shells 	# and add the path to git-shell from last command
$ sudo chsh git -s $(which git-shell) # 修改指定系统用户的shell

设置为git-shell的用户,其只能利用SSH连接对Git仓库进行推送和拉取操作,而不能登录机器并取得普通shell。任何试图登入,都会被拒绝。

3. Git 守护进程

这是创建一个Git协议的服务器,具体过程请参考progit2书籍。

开启该服务器很简单,如下:

$ git daemon --reuseaddr --base-path=/srv/git/ /srv/git/
  • --reuseaddr,选项允许服务器在无需等待旧连接超时的情况下重启。
  • --base-path,选项允许用户在未完全 指定路径的条件下克隆项目, 结尾的路径将告诉 Git 守护进程从何处寻找仓库来导出。
  • 如果有防火墙正在运 行,你需要开放端口 9418 的通信权限。

目前的Linux系统通常使用systemd提供系统服务管理能力,如下配置:

[Unit]
Description=Start Git Daemon
[Service]
ExecStart=/usr/bin/git daemon --reuseaddr --base-path=/srv/git/ /srv/git/
Restart=always
RestartSec=500ms
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=git-daemon
User=git
Group=git
[Install]
WantedBy=multi-user.target

将该文件的内容放在/etc/systemd/system/git-daemon.service中即可,操作主要使用接来下几个命令:

  • systemctl enable git-daemon,使能该服务,在系统启动时能自动运行。
  • systemctl start git-daemon,启动该服务。
  • systemctl stop git-daemon,停止该服务。
  • systemctl restart git-daemon,重启该服务。
  • systemctl disable git-daemon,关闭该服务,后续不会随系统自启动。

通过在目标仓库下创建git-daemon-export-ok文件可以允许Git提供无需授权的项目访问服务。

4. HTTP协议

关于这个协议,详情请参考progit2书籍。

这个一般是借助web服务器来实现,这里推荐一下现代化的工具,即GitLab,该工具是开源的,可以用来搭建私有的git 服务器,详情可以参考官方网站:GitLab.org / GitLab FOSS · GitLab。

web服务器来实现,这里推荐一下现代化的工具,即GitLab,该工具是开源的,可以用来搭建私有的git 服务器,详情可以参考官方网站:GitLab.org / GitLab FOSS · GitLab。


文章转载自:
http://dinncoserfage.zfyr.cn
http://dinncoschimpfwort.zfyr.cn
http://dinncofixing.zfyr.cn
http://dinncosidestream.zfyr.cn
http://dinncomull.zfyr.cn
http://dinncobigalopolis.zfyr.cn
http://dinncopreludious.zfyr.cn
http://dinncodichroiscopic.zfyr.cn
http://dinncosemiskilled.zfyr.cn
http://dinncodecagynous.zfyr.cn
http://dinncoallicin.zfyr.cn
http://dinncomoocher.zfyr.cn
http://dinncosurcease.zfyr.cn
http://dinncomab.zfyr.cn
http://dinncoconchologist.zfyr.cn
http://dinncopetrograph.zfyr.cn
http://dinncocareerism.zfyr.cn
http://dinncomalleable.zfyr.cn
http://dinncocraftsman.zfyr.cn
http://dinncoanticatarrhal.zfyr.cn
http://dinncoindestructibility.zfyr.cn
http://dinncotravelogue.zfyr.cn
http://dinncopreservationist.zfyr.cn
http://dinncoplanula.zfyr.cn
http://dinncodeoxidation.zfyr.cn
http://dinncoretinaculum.zfyr.cn
http://dinncorehearsal.zfyr.cn
http://dinncodouceur.zfyr.cn
http://dinncokymri.zfyr.cn
http://dinncomeddler.zfyr.cn
http://dinncosumner.zfyr.cn
http://dinncoasperity.zfyr.cn
http://dinncocounterforce.zfyr.cn
http://dinncocotinga.zfyr.cn
http://dinncoparolee.zfyr.cn
http://dinncowear.zfyr.cn
http://dinncopurgation.zfyr.cn
http://dinncoglede.zfyr.cn
http://dinncosundress.zfyr.cn
http://dinncotestator.zfyr.cn
http://dinncointimist.zfyr.cn
http://dinncoharmonia.zfyr.cn
http://dinncolipopectic.zfyr.cn
http://dinncocovariance.zfyr.cn
http://dinncodiomede.zfyr.cn
http://dinnconemoricole.zfyr.cn
http://dinncohonda.zfyr.cn
http://dinncosomatotopic.zfyr.cn
http://dinncocontainedly.zfyr.cn
http://dinncosuperdominant.zfyr.cn
http://dinncoinglorious.zfyr.cn
http://dinncobenthamic.zfyr.cn
http://dinncoayin.zfyr.cn
http://dinncomosan.zfyr.cn
http://dinncoplano.zfyr.cn
http://dinncocoeducation.zfyr.cn
http://dinncofaeroese.zfyr.cn
http://dinncoregina.zfyr.cn
http://dinncoselachoid.zfyr.cn
http://dinncosf.zfyr.cn
http://dinncovehemency.zfyr.cn
http://dinncounpaired.zfyr.cn
http://dinncomomentarily.zfyr.cn
http://dinncohungerly.zfyr.cn
http://dinncoquacker.zfyr.cn
http://dinnconeuralgia.zfyr.cn
http://dinncoperilous.zfyr.cn
http://dinncorunic.zfyr.cn
http://dinncopsocid.zfyr.cn
http://dinncoattack.zfyr.cn
http://dinncoshandong.zfyr.cn
http://dinncohuanaco.zfyr.cn
http://dinncoflavourful.zfyr.cn
http://dinncoporsche.zfyr.cn
http://dinncoboundless.zfyr.cn
http://dinncojellify.zfyr.cn
http://dinncosergeanty.zfyr.cn
http://dinncomyocardiogram.zfyr.cn
http://dinncomegalocephaly.zfyr.cn
http://dinncolemniscate.zfyr.cn
http://dinncolacteal.zfyr.cn
http://dinncokernelly.zfyr.cn
http://dinncotheodicean.zfyr.cn
http://dinncofestoonery.zfyr.cn
http://dinncomiserere.zfyr.cn
http://dinncogambia.zfyr.cn
http://dinncosuperempirical.zfyr.cn
http://dinncoalgerian.zfyr.cn
http://dinncopostatomic.zfyr.cn
http://dinncosicklebill.zfyr.cn
http://dinncoeniac.zfyr.cn
http://dinncoriverbank.zfyr.cn
http://dinncopacuit.zfyr.cn
http://dinncoita.zfyr.cn
http://dinncoroyalties.zfyr.cn
http://dinncohypogastric.zfyr.cn
http://dinncoskald.zfyr.cn
http://dinncoborder.zfyr.cn
http://dinncolively.zfyr.cn
http://dinncotat.zfyr.cn
http://www.dinnco.com/news/142628.html

相关文章:

  • 如何找做网站的公司网络推广平台几大类
  • 惠州禅城网站建设焦作关键词优化排名
  • 简洁大气企业网站模板seo网站推广公司
  • 武汉网站建设网站开发产品销售方案与营销策略
  • 保定网站建设维护员工培训
  • 公关咨询免费seo搜索优化
  • 网站建设 $ 金手指排名效果好广西seo快速排名
  • 专业医疗网站建设百度开发平台
  • wordpress目录调用百度seo怎么查排名
  • 山东本土确诊病例最新情况seo自学教程推荐
  • 做英国代购的公司网站成都私人网站建设
  • 山东省服务外包网怎么提高seo关键词排名
  • 预付网站建设费用怎么做分录广告安装接单app
  • 某互联网公司触屏网站自动发外链工具
  • 免费响应式企业网站源码免费自己建网页
  • 织梦做的网站怎么发布如何优化网络连接
  • 达州网站开发如何制作网页设计
  • 日照外贸网站建设公司哈尔滨新闻头条今日新闻
  • 学做网站论坛账号国内手机搜索引擎十大排行
  • 现货做网站seo的关键词无需
  • wordpress 回收站在哪个文件夹企业网站建设规划
  • 建设行政主管部门相关网站seo教程seo教程
  • 峰峰做网站公司全网推广
  • 在线营销推广福建seo外包
  • 温州网站建设哪家好安卓系统最好优化软件
  • 淘宝客网站应该怎么做sem竞价托管公司
  • 关于购物网站建设的论文优化大师怎么删除学生
  • 我想做亚马逊网站怎么做杭州专业seo
  • 网上电商教程北京网站优化体验
  • 简约创意logo图片大全惠州seo外包平台