<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Git_尚硅谷 on 随记</title><link>https://blog.liuyi2026.asia/zh/tags/git_%E5%B0%9A%E7%A1%85%E8%B0%B7/</link><description>Recent content in Git_尚硅谷 on 随记</description><generator>Hugo</generator><language>zh</language><lastBuildDate>Sun, 24 Jul 2022 16:46:04 +0000</lastBuildDate><atom:link href="https://blog.liuyi2026.asia/zh/tags/git_%E5%B0%9A%E7%A1%85%E8%B0%B7/index.xml" rel="self" type="application/rss+xml"/><item><title>19-26_git_尚硅谷</title><link>https://blog.liuyi2026.asia/zh/docs/technology/Git/git_sgg_/19-26/</link><pubDate>Sun, 24 Jul 2022 16:46:04 +0000</pubDate><guid>https://blog.liuyi2026.asia/zh/docs/technology/Git/git_sgg_/19-26/</guid><description>&lt;h1 id="介绍">介绍&lt;a class="anchor" href="#%e4%bb%8b%e7%bb%8d">#&lt;/a>&lt;/h1>
&lt;p>使用代码托管中心（远程服务器）
&lt;img src="img/ly-20241212142124425.png" alt="ly-20241212142124425" />&lt;/p>
&lt;ul>
&lt;li>团队内写作
push&amp;ndash;clone&amp;ndash;push&amp;mdash;
&amp;ndash;pull
&lt;img src="img/ly-20241212142124625.png" alt="ly-20241212142124625" />&lt;/li>
&lt;li>跨团队写作
fork（到自己的远程库）&amp;mdash;clone
&lt;img src="img/ly-20241212142124707.png" alt="ly-20241212142124707" />&lt;/li>
&lt;/ul>
&lt;h1 id="创建远程库创建别名">创建远程库&amp;amp;创建别名&lt;a class="anchor" href="#%e5%88%9b%e5%bb%ba%e8%bf%9c%e7%a8%8b%e5%ba%93%e5%88%9b%e5%bb%ba%e5%88%ab%e5%90%8d">#&lt;/a>&lt;/h1>
&lt;ul>
&lt;li>官网：https://github.com&lt;/li>
&lt;li>现在yuebuqun注册一个账号
创建一个远程库git-demo，创建成功
&lt;img src="img/ly-20241212142124787.png" alt="ly-20241212142124787" />&lt;/li>
&lt;li>创建远程库别名
git remote -v （查看别名）
为远程库创建别名
&lt;code>git remote add git-demo https://github.com/lwmfjc/git-demo.git&lt;/code>
别名创建成功 fetch和push都可以使用别名
&lt;img src="img/ly-20241212142124868.png" alt="ly-20241212142124868" />&lt;/li>
&lt;/ul>
&lt;h1 id="推送本地库到远程库">推送本地库到远程库&lt;a class="anchor" href="#%e6%8e%a8%e9%80%81%e6%9c%ac%e5%9c%b0%e5%ba%93%e5%88%b0%e8%bf%9c%e7%a8%8b%e5%ba%93">#&lt;/a>&lt;/h1>
&lt;ul>
&lt;li>推送master分支
切换&lt;code>git checkout master&lt;/code>&lt;/li>
&lt;li>推送
git push git-demo master
&lt;img src="img/ly-20241212142124947.png" alt="ly-20241212142124947" />&lt;/li>
&lt;/ul>
&lt;h1 id="拉取远程库到本地库">拉取远程库到本地库&lt;a class="anchor" href="#%e6%8b%89%e5%8f%96%e8%bf%9c%e7%a8%8b%e5%ba%93%e5%88%b0%e6%9c%ac%e5%9c%b0%e5%ba%93">#&lt;/a>&lt;/h1>
&lt;ul>
&lt;li>&lt;code>git pull git-demo master&lt;/code>
结果
&lt;img src="img/ly-20241212142125028.png" alt="ly-20241212142125028" />&lt;/li>
&lt;/ul>
&lt;h1 id="克隆远程库到本地">克隆远程库到本地&lt;a class="anchor" href="#%e5%85%8b%e9%9a%86%e8%bf%9c%e7%a8%8b%e5%ba%93%e5%88%b0%e6%9c%ac%e5%9c%b0">#&lt;/a>&lt;/h1>
&lt;ul>
&lt;li>git clone xxxxxxx/git-demo.git
&lt;img src="img/ly-20241212142125111.png" alt="ly-20241212142125111" />
clone之后有默认的别名，且已经初始化了本地库&lt;/li>
&lt;/ul>
&lt;h1 id="团队内写作">团队内写作&lt;a class="anchor" href="#%e5%9b%a2%e9%98%9f%e5%86%85%e5%86%99%e4%bd%9c">#&lt;/a>&lt;/h1>
&lt;ul>
&lt;li>lhc修改了git-demo下的hello.txt&lt;/li>
&lt;li>之后进行git add hello.txt&lt;/li>
&lt;li>git commit -m &amp;ldquo;lhc-commit &amp;quot; hello.txt&lt;/li>
&lt;li>现在进行push
git push origin master
出错了
&lt;img src="img/ly-20241212142125194.png" alt="ly-20241212142125194" />&lt;/li>
&lt;li>使用ybq，对库进行设置，管理成员
&lt;img src="img/ly-20241212142125275.png" alt="ly-20241212142125275" />&lt;/li>
&lt;li>添加成员即可
输入账号名
&lt;img src="img/ly-20241212142125354.png" alt="ly-20241212142125354" />&lt;/li>
&lt;li>将邀请函
&lt;img src="img/ly-20241212142125433.png" alt="ly-20241212142125433" />
发送给lhc
&lt;img src="img/ly-20241212142125516.png" alt="ly-20241212142125516" />&lt;/li>
&lt;li>现在再次推送，则推送成功
&lt;img src="img/ly-20241212142125598.png" alt="ly-20241212142125598" />&lt;/li>
&lt;/ul>
&lt;h1 id="团队外合作">团队外合作&lt;a class="anchor" href="#%e5%9b%a2%e9%98%9f%e5%a4%96%e5%90%88%e4%bd%9c">#&lt;/a>&lt;/h1>
&lt;ul>
&lt;li>
&lt;p>先把别人的项目fork下来
&lt;img src="img/ly-20241212142125682.png" alt="ly-20241212142125682" />&lt;/p></description></item><item><title>09-18_git_尚硅谷</title><link>https://blog.liuyi2026.asia/zh/docs/technology/Git/git_sgg_/09-18/</link><pubDate>Sat, 23 Jul 2022 09:39:11 +0000</pubDate><guid>https://blog.liuyi2026.asia/zh/docs/technology/Git/git_sgg_/09-18/</guid><description>&lt;h1 id="命令">命令&lt;a class="anchor" href="#%e5%91%bd%e4%bb%a4">#&lt;/a>&lt;/h1>
&lt;ol>
&lt;li>
&lt;p>命令-设置用户签名&lt;/p>
&lt;ul>
&lt;li>查看
&lt;code>git config user.name&lt;/code>
&lt;code>git config user.email&lt;/code>&lt;/li>
&lt;li>设置
&lt;code>git config --global user.name ly001&lt;/code>
&lt;code>git config --global user.email xxx@xx.com&lt;/code>&lt;/li>
&lt;li>git的配置文件查看
&lt;img src="img/ly-20241212142119718.png" alt="ly-20241212142119718" />&lt;/li>
&lt;li>作用：区分不同操作者身份，跟后面登陆的账号没有关系&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>初始化本地库&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;code>git init &lt;/code>&lt;/p>
&lt;p>&lt;img src="img/ly-20241212142119957.png" alt="ly-20241212142119957" />
多出一个文件夹
&lt;img src="img/ly-20241212142120049.png" alt="ly-20241212142120049" />&lt;/p>
&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>查看本地库状态&lt;/p>
&lt;ul>
&lt;li>&lt;code>git status&lt;/code>
&lt;img src="img/ly-20241212142120138.png" alt="ly-20241212142120138" />
默认在master分支&lt;/li>
&lt;li>新增一个文件
&lt;code>vim hello.txt&lt;/code>
&lt;img src="img/ly-20241212142120222.png" alt="ly-20241212142120222" />&lt;/li>
&lt;li>此时查看本地库的状态
&lt;img src="img/ly-20241212142120310.png" alt="ly-20241212142120310" />
untracketd files 未被追踪的文件，也就是这个文件还在工作区&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>添加暂存区&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;code>git add hello.txt&lt;/code>
&lt;img src="img/ly-20241212142120403.png" alt="ly-20241212142120403" />
LF 将会被替换成 CRLF，windows里面是CRLF，也就是说&lt;/p>
&lt;blockquote class='book-hint '>
&lt;p>这个&lt;code>换行符自动转换&lt;/code>会把自动把你代码里 与你当前操作系统不相同的换行的方式 转换成当前系统的换行方式（即&lt;code>LF&lt;/code>和&lt;code>CRLF&lt;/code> 之间的转换）&lt;/p>&lt;/blockquote>&lt;p>这是因为这个hello.txt是使用&lt;code>vm hello.txt&lt;/code>在git bash里面添加的，如果直接在windows文件管理器添加一个文件（hello2.txt)，就会发现没有这个警告，因为他已经是CRLF了 （为了和视频保持一致，git rm &amp;ndash;cached hello2.txt 后删除这个文件）
&lt;img src="img/ly-20241212142120487.png" alt="ly-20241212142120487" />&lt;/p>
&lt;/li>
&lt;li>
&lt;p>查看当前状态，绿色表示git已经追踪到了这个文件&lt;/p>
&lt;p>文件已经存在于暂存区
&lt;img src="img/ly-20241212142120577.png" alt="ly-20241212142120577" />&lt;/p>
&lt;/li>
&lt;li>
&lt;p>使用&lt;code>git rm --cached hello.txt&lt;/code>可以将文件从暂存区删除
使用后，文件又出现在工作区了（未添加）
&lt;img src="img/ly-20241212142120667.png" alt="ly-20241212142120667" />&lt;/p></description></item><item><title>01-08_git_尚硅谷</title><link>https://blog.liuyi2026.asia/zh/docs/technology/Git/git_sgg_/01-08/</link><pubDate>Wed, 20 Jul 2022 21:57:18 +0000</pubDate><guid>https://blog.liuyi2026.asia/zh/docs/technology/Git/git_sgg_/01-08/</guid><description>&lt;h1 id="概述">概述&lt;a class="anchor" href="#%e6%a6%82%e8%bf%b0">#&lt;/a>&lt;/h1>
&lt;h2 id="课程介绍">课程介绍&lt;a class="anchor" href="#%e8%af%be%e7%a8%8b%e4%bb%8b%e7%bb%8d">#&lt;/a>&lt;/h2>
&lt;ol>
&lt;li>Git
- git介绍&amp;ndash;分布式版本控制+集中式版本控制
- git安装&amp;ndash;基于官网，2.31.1 windows
- 基于开发案例 详细讲解常用命令
- git分支&amp;mdash;特性、创建、转换、合并、代码合并冲突解决
- idea集成git&lt;/li>
&lt;li>Github
&lt;ul>
&lt;li>如何创建远程库&lt;/li>
&lt;li>推送 push&lt;/li>
&lt;li>拉取 pull&lt;/li>
&lt;li>克隆 clone&lt;/li>
&lt;li>ssh免密登录&lt;/li>
&lt;li>idea github集成&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>Gitee码云
&lt;ul>
&lt;li>码云创建远程库&lt;/li>
&lt;li>Idea集成Gitee&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>Gitlab
&lt;ul>
&lt;li>gitlab服务器的搭建和部署&lt;/li>
&lt;li>idea集成gitlab&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>课程目标：五个小时，熟练掌握git、github、gitee&lt;/li>
&lt;/ol>
&lt;h2 id="官网介绍">官网介绍&lt;a class="anchor" href="#%e5%ae%98%e7%bd%91%e4%bb%8b%e7%bb%8d">#&lt;/a>&lt;/h2>
&lt;ol>
&lt;li>git是免费的开源的分布式版本控制系统&lt;/li>
&lt;li>廉价的本地库&lt;/li>
&lt;li>分支功能
&lt;img src="img/ly-20241212142118069.png" alt="ly-20241212142118069" />&lt;/li>
&lt;li>Everything is local&lt;/li>
&lt;/ol>
&lt;h2 id="版本控制介绍">版本控制介绍&lt;a class="anchor" href="#%e7%89%88%e6%9c%ac%e6%8e%a7%e5%88%b6%e4%bb%8b%e7%bb%8d">#&lt;/a>&lt;/h2>
&lt;ol>
&lt;li>记录文件内容变化，以便将来查阅特定版本修订记录的系统&lt;/li>
&lt;li>如果没有git
&lt;img src="img/ly-20241212142118196.png" alt="ly-20241212142118196" />&lt;/li>
&lt;li>为什么需要版本控制（从个人开发过渡到团队合作）
&lt;img src="img/ly-20241212142118292.png" alt="ly-20241212142118292" />&lt;/li>
&lt;/ol>
&lt;h2 id="分布式版本控制vs集中式版本控制">分布式版本控制VS集中式版本控制&lt;a class="anchor" href="#%e5%88%86%e5%b8%83%e5%bc%8f%e7%89%88%e6%9c%ac%e6%8e%a7%e5%88%b6vs%e9%9b%86%e4%b8%ad%e5%bc%8f%e7%89%88%e6%9c%ac%e6%8e%a7%e5%88%b6">#&lt;/a>&lt;/h2>
&lt;ol>
&lt;li>SVN，单一的集中管理的服务器，保存所有文件的修订版本。其他人都先连到这个中央服务器上获取最新处理是否冲突
&lt;img src="img/ly-20241212142118383.png" alt="ly-20241212142118383" />&lt;/li>
&lt;/ol>
&lt;ul>
&lt;li>缺点，单点故障，如果某段时间内故障了，那么就没法提交&lt;/li>
&lt;/ul>
&lt;ol start="2">
&lt;li>Git，每台电脑都是代码库
&lt;img src="img/ly-20241212142118467.png" alt="ly-20241212142118467" />
&lt;ul>
&lt;li>如果远程库挂了，本地还是可以做版本控制的，只不过不能做代码推送而已&lt;/li>
&lt;li>每个客户端保存的都是完整的项目（包括历史记录）&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ol>
&lt;h2 id="发展历史">发展历史&lt;a class="anchor" href="#%e5%8f%91%e5%b1%95%e5%8e%86%e5%8f%b2">#&lt;/a>&lt;/h2>
&lt;ol>
&lt;li>linux系统版本控制历史
&lt;ul>
&lt;li>1991-2002 手动合并&lt;/li>
&lt;li>2002 BitKeeper授权Linux社区免费使用（版本控制系统）
&lt;ul>
&lt;li>社区将其破解&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>2005 用C语言开发了一个分布式版本控制系统：Git
两周开发时间&lt;/li>
&lt;li>2008年 GitHub上线&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ol>
&lt;h2 id="工作机制和代码托管中心">工作机制和代码托管中心&lt;a class="anchor" href="#%e5%b7%a5%e4%bd%9c%e6%9c%ba%e5%88%b6%e5%92%8c%e4%bb%a3%e7%a0%81%e6%89%98%e7%ae%a1%e4%b8%ad%e5%bf%83">#&lt;/a>&lt;/h2>
&lt;p>&lt;img src="img/ly-20241212142118560.png" alt="ly-20241212142118560" />&lt;/p></description></item></channel></rss>