zoukankan      html  css  js  c++  java
  • 建立自己的git服务器

    需求情景

    就像金山快盘同步盘那样, 在开发环境windows 10和部署环境Ubuntu server 14.04之间建立同步关系.比如windows端多了一个a.txt文件,你推送后,Ubuntu端也就会增加一个同样的a.txt文件.注意,现在网络上许多关于git远程仓库的教程其实都不是把文件原原本本地推送到服务器上的.它们只是建立一个裸仓库,这个仓库能供其他主机clone.

    假设

    比如我是想在win端c:projectsabc和Ubuntu端/root/projects/abc建立同步关系,服务器的域名是example.com.

    分别在windows和Ubuntu安装git

    git的版本需要不小于2.3

    windows安装git

    windows比较简单,点击这里进行

    Ubuntu安装git

    这个可能要麻烦一些,比如阿里云服务器,你用apt-get install git的方式安装只能得到1.9的版本.如果是这种情况,就需要手动从源码安装.
    查看安装方法

    配置git

    安装成功后,两端都需要配置一下基本信息.
    git config --global user.email "you@example.com"
    git config --global user.name "Your Name"

    配置ssh key

    windows端在git bash界面进行(这个安装了git之后自然就会有).之后请参照这个教程进行.

    建立仓库

    win端

    cd "c:projectsabc"
    git init && git add -A && git commit -m "first commit"
    git remote add origin root@example.com:/root/projects/abc/.git/
    

    ubuntu端

    cd /root/projects/abc
    git init
    git config receive.denyCurrentBranch updateInstead
    

    回到win端

    git push -u origin --all
    

    搞定.

  • 相关阅读:
    <span>和<div>标签的隐藏和显示切换
    重启svn
    Mac下配置apache
    iOS时间显示今天昨天
    关于UIPageViewController那些事
    关于plist文件的那些事
    Xcode调试LLDB
    Reveal安装
    静态初始化器
    Static简介
  • 原文地址:https://www.cnblogs.com/xiangnan/p/5222817.html
Copyright © 2011-2022 走看看