2018年6月

自摘: 林德熙博客 http://blog.csdn.net/lindexi_gd

在合并pull两个不同的项目,会出现的问题: refusing to merge unrelated histories

先pull,因为两个仓库不同,发现refusing to merge unrelated histories

无法pull

因为他们是两个不同的项目,要把两个不同的项目合并,git需要添加一句代码,在git pull,这句代码是在git 2.9.2版本发生的,最新的版本需要添加--allow-unrelated-histories

假如我们的源是origin,分支是master,那么我们 需要这样写

git pull origin master --allow-unrelated-histories

需要知道,我们的源可以是本地的路径

咱们做开发的,被墙掉了真的很郁闷,有时候想看个资料,下载个开发工具啥的,真的很苦闷无语

自己搞个代理服务器吧

需要共享的小伙伴可以留言哈

不错大家拿去别做违法犯忌的事,另外不要从事较大的流量传输活动哦,本人小小码农有点负担不起哦。

我们可以通过git version确定当前的git版本(如果小于2.0,更新是个更好的选择),通过
git config --global push.default [option]
改变push.default的默认行为(或者也可直接编辑~/.gitconfig文件)。

push.default 有以下几个可选值:
nothing, current, upstream, simple, matching

其用途分别为:

nothing - push操作无效,除非显式指定远程分支,例如git push origin develop(我觉得。。。可以给那些不愿学git的同事配上此项)。

current - push当前分支到远程同名分支,如果远程同名分支不存在则自动创建同名分支。

upstream - push当前分支到它的upstream分支上(这一项其实用于经常从本地分支push/pull到同一远程仓库的情景,这种模式叫做central workflow)。

simple - simple和upstream是相似的,只有一点不同,simple必须保证本地分支和它的远程 upstream分支同名,否则会拒绝push操作。

matching - push所有本地和远程两端都存在的同名分支

git pull
弄清楚git push的默认行为后,再来看看git pull。

当我们未指定当前分支的upstream时,通常git pull操作会得到如下的提示:

There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details

git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream-to=origin/<branch> new1

git pull的默认行为和git push完全不同。
当我们执行git pull的时候,实际上是做了git fetch + git merge操作,fetch操作将会更新本地仓库的remote tracking,也就是refs/remotes中的代码,并不会对refs/heads中本地当前的代码造成影响。

当我们进行pull的第二个行为merge时,对git来说,如果我们没有设定当前分支的upstream,它并不知道我们要合并哪个分支到当前分支,所以我们需要通过下面的代码指定当前分支的upstream:

git branch --set-upstream-to=origin/ develop
// 或者git push --set-upstream origin develop
实际上,如果我们没有指定upstream,git在merge时会访问git config中当前分支(develop)merge的默认配置,我们可以通过配置下面的内容指定某个分支的默认merge操作

[branch "develop"]
remote = origin
merge = refs/heads/develop // [1]为什么不是refs/remotes/develop?

或者通过command-line直接设置:

git config branch.develop.merge refs/heads/develop
这样当我们在develop分支git pull时,如果没有指定upstream分支,git将根据我们的config文件去merge origin/develop;如果指定了upstream分支,则会忽略config中的merge默认配置。

以上就是git push和git pull操作的全部默认行为,如有错误,欢迎斧正

申请网址:https://freessl.org/

1. 安装 acme.sh
安装很简单, 一个命令:

curl https://get.acme.sh | sh -s email=my@example.com

普通用户和 root 用户都可以安装使用. 安装过程进行了以下几步:

把 acme.sh 安装到你的 home 目录下:

~/.acme.sh/

并创建 一个 shell 的 alias, 例如 .bashrc,方便你的使用: alias acme.sh=~/.acme.sh/acme.sh

自动为你创建 cronjob, 每天 0:00 点自动检测所有的证书, 如果快过期了, 需要更新, 则会自动更新证书.
更高级的安装选项请参考: https://github.com/Neilpang/acme.sh/wiki/How-to-install

安装过程不会污染已有的系统任何功能和文件, 所有的修改都限制在安装目录中: ~/.acme.sh/

中国大陆用户请参考:

https://github.com/acmesh-official/acme.sh/wiki/Install-in-China

以上链接说明内容如下:
如果你的安装服务器位于中国大陆境内, 访问 github 可能会不成功. 所以安装可能会失败.

推荐从这里下载安装:

#centos7.9系统,实操时报错:No such file or directory
https://gitee.com/neilpang/acme.sh

#从原仓库复制了一个20240120
https://e.coding.net/youxianbo/tools/acme.sh.git

安装步骤:
根据 How-to-install#3-or-git-clone-and-install

git clone https://gitee.com/neilpang/acme.sh.git
cd acme.sh
./acme.sh --install -m my@example.com

在freessl.cn注册账号,然后使用这个平台的 ACME 自动化 服务
https://freessl.cn/acme-deploy

ACME 域名管理里面添加域名、并验证后,就可以申请证书了
验证域名如果选用Http-proxy的话,安照提示需要在网站上配置一下代理(xxxx替换)

 location ^~ /.well-known/acme-challenge/ {
    proxy_pass https://acme-http-proxy.certcloud.cn/http-challenge/xxxx/;
 }

然后在安装好acme的服务器执行证书申请命令,例如(xxxx替换):

#单域名证书
acme.sh --issue -d www.xxxx.com  --dns dns_dp --server https://acme.freessl.cn/v2/DV90/directory/xxxx
#多域名证书(一个证书可以同时支持多个域名使用)
acme.sh --issue -d www.xxx.com -d www.xxx.com -d www.xxx.com --dns dns_dp --server https://acme.freessl.cn/v2/DV90/directory/xxxx

copy/安装 证书
前面证书生成以后, 接下来需要把证书 copy 到真正需要用它的地方.

注意, 默认生成的证书都放在安装目录下: ~/.acme.sh/, 请不要直接使用此目录下的文件, 例如: 不要直接让 nginx/apache 的配置文件使用这下面的文件. 这里面的文件都是内部使用, 而且目录结构可能会变化.

正确的使用方法是使用 --install-cert 命令,并指定目标位置, 然后证书文件会被copy到相应的位置, 例如:

Apache example:
acme.sh --install-cert -d example.com \
--cert-file /path/to/certfile/in/apache/cert.pem \
--key-file /path/to/keyfile/in/apache/key.pem \
--fullchain-file /path/to/fullchain/certfile/apache/fullchain.pem \
--reloadcmd "service apache2 force-reload"

Nginx example:
acme.sh --install-cert -d example.com \
--key-file /path/to/keyfile/in/nginx/key.pem \
--fullchain-file /path/to/fullchain/nginx/cert.pem \
--reloadcmd "service nginx force-reload"
(一个小提醒, 这里用的是 service nginx force-reload, 不是 service nginx reload, 据测试, reload 并不会重新加载证书, 所以用的 force-reload)

Chain issues Incomplete 错误的解决办法
Nginx 的配置 ssl_certificate 使用 /etc/nginx/ssl/fullchain.cer ,而非 /etc/nginx/ssl/.cer ,否则 SSL Labs 的测试会报 Chain issues Incomplete 错误。

--install-cert命令可以携带很多参数, 来指定目标文件. 并且可以指定 reloadcmd, 当证书更新以后, reloadcmd会被自动调用,让服务器生效.

详细参数请参考: https://github.com/Neilpang/acme.sh#3-install-the-issued-cert-to-apachenginx-etc

值得注意的是, 这里指定的所有参数都会被自动记录下来, 并在将来证书自动更新以后, 被再次自动调用.

检测网站证书

https://www.ssllabs.com/ssltest/index.html
https://myssl.com/dns_check.html#ssl_verify

更多证书相关工具

https://freessl.cn/ssltools

./configure -prefix=/usr/local/php7 -with-config-file-path=/usr/local/php7/etc -with-mcrypt=/usr/include -enable-mysqlnd -with-gd -with-iconv -with-zlib -enable-bcmath -enable-shmop -enable-sysvsem -enable-inline-optimization -enable-mbregex -enable-fpm -enable-mbstring -enable-ftp -enable-gd-native-ttf -with-openssl -enable-pcntl -enable-sockets -with-xmlrpc -enable-zip -enable-soap -with-gettext -with-curl -with-jpeg-dir -with-freetype-dir -with-mysqli -enable-embedded-mysqli -with-pdo-mysql