<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>git &#8211; 编程技术记录</title>
	<atom:link href="https://blog.z6z8.cn/tag/git/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.z6z8.cn</link>
	<description>世界你好!</description>
	<lastBuildDate>Fri, 27 Nov 2020 10:02:24 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
	<item>
		<title>macos 配置 git ssh访问方式</title>
		<link>https://blog.z6z8.cn/2020/11/27/macos-%e9%85%8d%e7%bd%ae-git-ssh%e8%ae%bf%e9%97%ae%e6%96%b9%e5%bc%8f/</link>
		
		<dc:creator><![CDATA[holdsky]]></dc:creator>
		<pubDate>Fri, 27 Nov 2020 10:02:24 +0000</pubDate>
				<category><![CDATA[安全运维]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[SSH]]></category>
		<guid isPermaLink="false">http://blog.z6z8.cn/?p=933</guid>

					<description><![CDATA[生成 ssh key $ ssh-keygen -t rsa -C "git服务端留存的邮箱地址" Gener [&#8230;]]]></description>
										<content:encoded><![CDATA[<h2>生成 ssh key</h2>
<pre><code class="language-shell">$ ssh-keygen -t rsa -C "git服务端留存的邮箱地址" 

Generating public/private rsa key pair.
Enter file in which to save the key (~/.ssh/id_rsa): "这里输入ssh key保存路径，不建议使用默认地址"
Enter passphrase (empty for no passphrase): "这里输入密码，建议输入空（方便后续配置）"
Enter same passphrase again: "再输入一遍密码,建议输入空（方便后续配置）"</code></pre>
<p>应生成两个文件，公钥和私钥，文件名形式为<code>xxx</code>(私钥)，<code>xxx_pub</code>或者<code>xxx.pub</code>(公钥)。记住ssh key生成的文件路径。</p>
<blockquote>
<p>默认情况下，ssh会使用<code>~/.ssh/id_rsa</code>这个私钥，但无法处理访问多个ssh远端的场景。</p>
</blockquote>
<h2>配置本地ssh访问git使用的私钥</h2>
<p>打开 <code>~/.ssh/config</code>文件，如果没有则创建一个文本文件，添加如下内容</p>
<pre><code class="language-shell"># 请保证 Host 和 HostName 的值相同 （macos11 实测不相同时，git ssh 访问失败）

# 远端ssh主机别名
Host bitbucket.cmbc.com.cn
    # 远端ssh主机名（域名或者ip都可以）
    HostName bitbucket.cmbc.com.cn
    # 鉴权文件 ，这填写ssh私钥文件路径
    IdentityFile "ssh 私钥文件路径"
    # 使用公钥算法进行鉴权
    PreferredAuthentications publickey</code></pre>
<p>关于 ssh config 更多细节参考 <a href="https://linux.die.net/man/5/ssh_config">https://linux.die.net/man/5/ssh_config</a></p>
<h2>配置git上的鉴权公钥</h2>
<p>不同的git服务方式不一样，以bitbucket为例：<br />
登录bitbucket，依次点击头像 -&gt; Manage account  -&gt; SSH keys -&gt; Add key ，</p>
<p>将ssh 公钥文件内容复制到在输入框中，然后 保存(点击 &quot;Add key&quot; 按钮)</p>
<blockquote>
<p>ssh 公钥形式通常是ssh-rsa  + base64编码的公钥 + 邮箱地址</p>
</blockquote>
<h2>配置本地已有git仓库的访问协议</h2>
<pre><code class="language-shell"># 查询远程仓库地址
git remote -v

# 添加ssh协议  地址需要访问网页版的bitbucket仓库获取
git remote set-url --add origin ssh://git@bitbucket.cmbc.com.cn:7999/xxx/xxx.git

# 删除http协议 地址由git remote -v获得
git remote set-url --delete origin http://usernamge@bitbucket.cmbc.com.cn:7999/scm/xxx/xxx.git </code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>git patch 文件冲突时的解决办法</title>
		<link>https://blog.z6z8.cn/2020/07/06/git-patch-%e6%96%87%e4%bb%b6%e7%9a%84%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95/</link>
		
		<dc:creator><![CDATA[holdsky]]></dc:creator>
		<pubDate>Mon, 06 Jul 2020 10:29:08 +0000</pubDate>
				<category><![CDATA[学习笔记]]></category>
		<category><![CDATA[安全运维]]></category>
		<category><![CDATA[git]]></category>
		<guid isPermaLink="false">http://blog.z6z8.cn/?p=875</guid>

					<description><![CDATA[生成patch 1、生成当前分支的patch 生成当前分支指定节点之后的所有patch 生成的patch，会根 [&#8230;]]]></description>
										<content:encoded><![CDATA[<h2>生成patch</h2>
<p>1、生成当前分支的patch</p>
<p>生成当前分支指定节点之后的所有patch<br />
生成的patch，会根据节点顺序自动编号，一个commit生成一个patch文件</p>
<pre><code class="language-shell">git format-patch 404777e8586393d5eb6581485fc1bb2bf2e8eb2a //这里长短commit id都可以</code></pre>
<p>2、生成两个节点之间的patch</p>
<pre><code class="language-shell">git format-patch  节点开始..节点结束 //这里长短commit id都可以
//例如
git format-patch aed12..ecf3a</code></pre>
<p>更多详细 <a href="https://blog.csdn.net/sunnylgz/article/details/7661920">https://blog.csdn.net/sunnylgz/article/details/7661920</a></p>
<h2>使用patch</h2>
<p>生成patch相对容易，使用时却有些麻烦，尤其是有冲突的时候。<br />
对于有冲突的patch，用搜索引擎搜索出的结果大都是</p>
<pre><code class="language-shell">git apply --reject patch文件
//对于冲突，会生成.rej文件，然后手动解决所有冲突</code></pre>
<p>这种办法在有冲突时，并不好用（因为根据.rej文件手动解决冲突比较麻烦）<br />
我尝试的一个简单方法是</p>
<pre><code class="language-shell">git am --3way patch文件
//解决冲突后
git am --continue</code></pre>
<p><code>--3way</code>，会尝试合并冲突到目标文件，而不是另生成.rej文件，这样的好处是可以使用成熟的冲突解决工具</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
