﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客--随笔分类-Git</title><link>http://www.cppblog.com/hkingSP/category/21381.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 12 Jul 2023 10:47:12 GMT</lastBuildDate><pubDate>Wed, 12 Jul 2023 10:47:12 GMT</pubDate><ttl>60</ttl><item><title>git rebase 到更新的master</title><link>http://www.cppblog.com/hkingSP/archive/2021/04/02/217650.html</link><dc:creator>宋鹏</dc:creator><author>宋鹏</author><pubDate>Fri, 02 Apr 2021 06:33:00 GMT</pubDate><guid>http://www.cppblog.com/hkingSP/archive/2021/04/02/217650.html</guid><wfw:comment>http://www.cppblog.com/hkingSP/comments/217650.html</wfw:comment><comments>http://www.cppblog.com/hkingSP/archive/2021/04/02/217650.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hkingSP/comments/commentRss/217650.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hkingSP/services/trackbacks/217650.html</trackback:ping><description><![CDATA[<div>1. Assume the following history exists and the current branch is "topic":</div><div></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A---B---C topic</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/</div><div>&nbsp;D---E---F---G master</div><div></div><div><br />From this point, the result of either of the following commands:</div><div></div><div>git rebase master</div><div>git rebase master topic</div><div></div><div><br />would be:</div><div></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;A'--B'--C' topic</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /</div><div>&nbsp;D---E---F---G master<br /><br />2. git rebase 过程中：<br />在修改完需要merge的文件后，用git add和git status来确认rebase状态，然后再git rebase --continue&nbsp;</div><img src ="http://www.cppblog.com/hkingSP/aggbug/217650.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hkingSP/" target="_blank">宋鹏</a> 2021-04-02 14:33 <a href="http://www.cppblog.com/hkingSP/archive/2021/04/02/217650.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>git tag and git describe a specified path/commits/tags</title><link>http://www.cppblog.com/hkingSP/archive/2021/01/13/217569.html</link><dc:creator>宋鹏</dc:creator><author>宋鹏</author><pubDate>Wed, 13 Jan 2021 02:40:00 GMT</pubDate><guid>http://www.cppblog.com/hkingSP/archive/2021/01/13/217569.html</guid><wfw:comment>http://www.cppblog.com/hkingSP/comments/217569.html</wfw:comment><comments>http://www.cppblog.com/hkingSP/archive/2021/01/13/217569.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hkingSP/comments/commentRss/217569.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hkingSP/services/trackbacks/217569.html</trackback:ping><description><![CDATA[<div>1.&nbsp;Create a tag with patterned name</div><div>git tag "tagname_v1.02"</div><div>(one tag is pointed to a specified commit)<br /></div><div>2. get tag describe to use in software version name</div><div>git describe --tags --long --dirty=* --match "tagname*"</div><div>&gt; tagname_v1.02-0-g59584af<br /><br />3. push tag name to remote repo</div><div>git push origin &lt;branchname&gt; --tags<br /></div><img src ="http://www.cppblog.com/hkingSP/aggbug/217569.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hkingSP/" target="_blank">宋鹏</a> 2021-01-13 10:40 <a href="http://www.cppblog.com/hkingSP/archive/2021/01/13/217569.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Git第三阶段：show log/show head/show modified/modify comment</title><link>http://www.cppblog.com/hkingSP/archive/2019/03/05/216287.html</link><dc:creator>宋鹏</dc:creator><author>宋鹏</author><pubDate>Tue, 05 Mar 2019 01:09:00 GMT</pubDate><guid>http://www.cppblog.com/hkingSP/archive/2019/03/05/216287.html</guid><wfw:comment>http://www.cppblog.com/hkingSP/comments/216287.html</wfw:comment><comments>http://www.cppblog.com/hkingSP/archive/2019/03/05/216287.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hkingSP/comments/commentRss/216287.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hkingSP/services/trackbacks/216287.html</trackback:ping><description><![CDATA[<strong>查看日志（本地commit记录）：</strong><br />git log<br />result:<br /><div>commit f46a2277acf6b1604f3268fcd3652682f23347bc (HEAD -&gt; master)</div><div>Author: songpeng &lt;song.peng@bizerba.com&gt;</div><div>Date:&nbsp; &nbsp;Mon Mar 4 17:07:09 2019 +0800</div><strong>查看日志中的某次提交：</strong><br />git show&nbsp;f46a2277acf6b1604f3268fcd3652682f23347bc&nbsp;<br />查看各个日志都修改了哪些文件：<br /><div>git log --name-only<br />查看各个日志文件的具体修改：<br />git log -p /path_you_specified</div><br /><strong>查看本地代码修改情况</strong>：<br />已修改，未add的变更：<br />git diff<br />已add，未commit的变更：<br />git diff --cached<br />上面两条合并：<br />git diff HEAD<br />两个commit之间的区别：<br /><div>git diff 0da94be&nbsp; 59ff30c</div><br /><strong>变更日志内容（comment）:</strong><br />首先显示最近3次提交的commit:<br /><span>git rebase -i HEAD~3<br /></span>运行后显示如下(我是在windows里面安装了vim,内容会显示在vim里，不知道没安装vim会如何显示)：<br /><div>pick 41b65c0 recursive_search_and_link_libraries</div><div>pick 0de33bd success_built_with_vs2013lib_on_creator</div><div>pick 7ed1e94 success to built with vs2013lib and run on vs2013 ide</div>移动光标到想要修改commit的所在行，将pick改成reword，然后保存<br />然后刷新的界面内类似会出现你想修改的comment，将之修改保存。<br />然后运行：<br />git push --force，就会重新传到服务器，更新你要修改的comment.<br /><br /><br /><div></div><div></div><img src ="http://www.cppblog.com/hkingSP/aggbug/216287.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hkingSP/" target="_blank">宋鹏</a> 2019-03-05 09:09 <a href="http://www.cppblog.com/hkingSP/archive/2019/03/05/216287.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Git第二阶段：add files/undo add/branch add/branch view/branch new/branch delete/branch push/pull remote to local files/fetch origin</title><link>http://www.cppblog.com/hkingSP/archive/2019/03/04/216286.html</link><dc:creator>宋鹏</dc:creator><author>宋鹏</author><pubDate>Mon, 04 Mar 2019 08:26:00 GMT</pubDate><guid>http://www.cppblog.com/hkingSP/archive/2019/03/04/216286.html</guid><wfw:comment>http://www.cppblog.com/hkingSP/comments/216286.html</wfw:comment><comments>http://www.cppblog.com/hkingSP/archive/2019/03/04/216286.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hkingSP/comments/commentRss/216286.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hkingSP/services/trackbacks/216286.html</trackback:ping><description><![CDATA[<p><strong>add:</strong><br />git add *<br /><br /><strong>undo add:</strong><br />You can undo&nbsp;git add&nbsp;before commit with</p> <p>git reset &lt;file&gt;&nbsp;</p> <p>which will remove it from the current index (the "about to be committed" list) without changing anything else.</p> <p>You can use</p> <p>git reset<br /><br /><strong>add brach:</strong><br />git branch rikSkinLoader<br /><br /><strong>view branch:</strong><br />git branch -a<br /><br /><strong>switch branch:</strong><br /><span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 11px; background-color: #ffffff;">git checkout BranchName</span><br /><br /><strong>delete branch:</strong><br />git branch -d<br /><br /><strong>push branch:</strong><br />git push origin branchname<br /><br /><strong>pull:</strong><br /><span>git pull origin &lt;remote_branch&gt;：&lt;local_branch&gt;</span><br />git pull origin master:master</p><p><br /></p><div style="display: inline-block;"><br /><strong>查看远端变更/后续操作：<br /></strong>git remote update</div><p>&nbsp;</p><div>First use git remote update, to bring your remote refs up to date. Then you can do one of several things, such as:</div><p><br /></p><div>git status -uno&nbsp;<br />git status -uno&nbsp;will tell you whether the branch you are tracking is ahead, behind or has diverged. If it says nothing, the local and remote are the same.</div><div>git show-branch *master</div><div>git show-branch *master will show you the commits in all of the branches whose names end in 'master' (eg master and origin/master).</div><img src ="http://www.cppblog.com/hkingSP/aggbug/216286.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hkingSP/" target="_blank">宋鹏</a> 2019-03-04 16:26 <a href="http://www.cppblog.com/hkingSP/archive/2019/03/04/216286.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Git第一阶段：入门操作(check in riles/checkout files)</title><link>http://www.cppblog.com/hkingSP/archive/2019/03/02/216277.html</link><dc:creator>宋鹏</dc:creator><author>宋鹏</author><pubDate>Sat, 02 Mar 2019 06:54:00 GMT</pubDate><guid>http://www.cppblog.com/hkingSP/archive/2019/03/02/216277.html</guid><wfw:comment>http://www.cppblog.com/hkingSP/comments/216277.html</wfw:comment><comments>http://www.cppblog.com/hkingSP/archive/2019/03/02/216277.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hkingSP/comments/commentRss/216277.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hkingSP/services/trackbacks/216277.html</trackback:ping><description><![CDATA[<strong style="font-family: Arial; font-size: 14pt;">clone</strong><span style="font-family: Arial; font-size: 14pt;">：</span><br style="font-family: Arial; font-size: 14pt;" /><span style="font-family: Arial; font-size: 14pt;">git clone&nbsp;</span><span style="font-family: Arial; font-size: 14pt;">https://github.com/songpeng22/HelloWorld.git<br /><br /></span><strong style="font-family: Arial; font-size: 14pt;">clone with username and password:</strong><span style="font-family: Arial; font-size: 14pt;"><br /></span><span style="font-family: Arial; font-size: 14pt;">git clone&nbsp;</span><span style="font-family: Arial; font-size: 14pt;">https://</span><span style="font-family: Arial; font-size: 14pt;">username</span><span style="font-family: Arial; font-size: 14pt;">:</span><span style="font-family: Arial; font-size: 14pt;">password</span><span style="font-family: Arial; font-size: 14pt;">@github.com/</span><span style="font-family: Arial; font-size: 14pt;">username</span><span style="font-family: Arial; font-size: 14pt;">/repository.git.<br /><br /><strong>clone old version:</strong><br /></span><div style="font-family: Arial; font-size: 14pt;">git clone git://sourceware.org/git/glibc.git<br /><div>cd glibc</div><div>git checkout glibc-2.28<br /><br /><strong>clone with tagname：</strong></div></div><span style="color: #4f4f4f; font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-variant-ligatures: common-ligatures; white-space: pre; background-color: #f6f8fa;">git clone http:</span><span style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; font-family: &quot;Microsoft YaHei&quot;, &quot;SF Pro Display&quot;, Roboto, Noto, Arial, &quot;PingFang SC&quot;, sans-serif; font-style: italic; overflow-wrap: break-word; font-variant-ligatures: common-ligatures; white-space: pre; color: #880000 !important;">//anongit.freedesktop.org/git/mesa/drm.git</span><br style="font-family: Arial; font-size: 18.6667px;" /><div style="font-family: Arial; font-size: 18.6667px;">cd drm</div><div style="font-family: Arial; font-size: 18.6667px;">git checkout -b&nbsp;<span style="color: #4f4f4f; font-family: &quot;Source Code Pro&quot;, &quot;DejaVu Sans Mono&quot;, &quot;Ubuntu Mono&quot;, &quot;Anonymous Pro&quot;, &quot;Droid Sans Mono&quot;, Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 14px; font-variant-ligatures: common-ligatures; white-space: pre; background-color: #f6f8fa;">libdrm-</span><span style="box-sizing: border-box; outline: 0px; margin: 0px; padding: 0px; font-family: &quot;Microsoft YaHei&quot;, &quot;SF Pro Display&quot;, Roboto, Noto, Arial, &quot;PingFang SC&quot;, sans-serif; font-size: 14px; overflow-wrap: break-word; font-variant-ligatures: common-ligatures; white-space: pre; color: #006666 !important;">2.4.102 libdrm-2.4.102
</span>or<br />git checkout tags/tagname -b &lt;branch&gt;<br />like above:<br />git checkout tags/libdrm-2.4.102 -b libdrm-2.4.102<br /></div><strong style="font-family: Arial; font-size: 14pt;">config:</strong><span style="font-family: Arial; font-size: 14pt;"><br /></span><span style="font-family: Arial; font-size: 14pt;">git config --global user.email "songpeng24@msn.com"</span><br style="font-family: Arial; font-size: 14pt;" /><span style="font-family: Arial; font-size: 14pt;">git config --global user.name 'songpeng22'<br /><br /></span><strong style="font-family: Arial; font-size: 14pt;">config status:</strong><span style="font-family: Arial; font-size: 14pt;"><br /></span><div style="font-family: Arial; font-size: 14pt;">git config -l<br /><br /><strong>project Status:</strong><br />git status</div><br style="font-family: Arial; font-size: 14pt;" /><strong style="font-family: Arial; font-size: 14pt;">在github上创建：<br /></strong><span style="font-family: Arial; font-size: 14pt;">https://github.com/songpeng22/CMake_QT_03_Qml-Standard.git</span><div style="font-family: Arial; font-size: 14pt;"><div><pre id="empty-setup-new-repo-echo"><span style="font-size: 14pt; font-family: Arial;">git init</span><span style="font-family: Arial; font-size: 14pt;">
</span><span style="font-size: 14pt; font-family: Arial;">git add README.md<br /></span><span style="font-size: 14pt; font-family: Arial;">git add *
</span><span style="font-size: 14pt; font-family: Arial;">git commit -m "first commit"</span><span style="font-family: Arial; font-size: 14pt;">
</span><span style="font-size: 14pt; font-family: Arial;">git remote add origin <span style="font-size: 14pt; font-family: Arial;">https://github.com/songpeng22/CMake_QT_03_Qml-Standard.git</span>
<span mb-0"="" style="font-size: 14pt; font-family: Arial;">git push -u origin master</span>
</span></pre></div></div><div style="font-family: Arial; font-size: 14pt;"><h3><br /></h3></div><span style="font-size: 14pt;"> </span><img src ="http://www.cppblog.com/hkingSP/aggbug/216277.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hkingSP/" target="_blank">宋鹏</a> 2019-03-02 14:54 <a href="http://www.cppblog.com/hkingSP/archive/2019/03/02/216277.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>