<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post/10404/</link>
<title><![CDATA[[实践OK]Git在存二进制文件时git add rsynctimer 出现fatal: rsynctimer 中的 CRLF 将被 LF 替换无法提交的解决办法。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[版本控制]]></category>
<pubDate>Fri, 10 Jan 2020 10:15:42 +0000</pubDate> 
<guid>http://www.jackxiang.com/post/10404/</guid> 
<description>
<![CDATA[ 
	git add rsynctimer <br/>fatal: playbook/bc.qr.*.cn/files/rsynctimer 中的 CRLF 将被 LF 替换<br/><br/>注意顺序，别搞反了：<br/><textarea name="code" class="php" rows="15" cols="100">
cat .gitattributes
* text eol=lf
* binary
</textarea><br/>上面这样修改后，git diff *.yml也认为是binary，无法git diff，还得这样，<br/>让.out是可执行程序，因为gcc hello.c -o hello.out<br/>于是 .out是可执行的二进制文件得了，作如下修改，正确如下：<br/><textarea name="code" class="php" rows="15" cols="100">
* .out binary
* text eol=lf diff
</textarea><br/><br/><br/><br/>it add playbook/bc.qr.*.cn/files/rsynctimer/rsynctimer.out<br/>fatal: playbook/bc.qr.*.cn/files/rsynctimer/rsynctimer.out 中的 CRLF 将被 LF 替换<br/><br/>git diff&nbsp;&nbsp;playbook/bc.qr.*.cn/bc_web.yml&nbsp;&nbsp; #正常git diff<br/><br/>以上实践来自：http://www.it1352.com/798609.html<br/>更多配置上的原理：https://www.jianshu.com/p/2a46dfd3705a
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post/9727/</link>
<title><![CDATA[Git 添加空文件夹的方法]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[版本控制]]></category>
<pubDate>Wed, 25 Apr 2018 05:45:51 +0000</pubDate> 
<guid>http://www.jackxiang.com/post/9727/</guid> 
<description>
<![CDATA[ 
	Create an empty file called .gitkeep in the directory, and add that.<br/><br/>来自：https://stackoverflow.com/questions/115983/how-can-i-add-an-empty-directory-to-a-git-repository<br/>From: https://www.zhihu.com/question/29811994
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post/9639/</link>
<title><![CDATA[[实践OK]请输入一个提交消息来解释为什么这个合并是必要的，Please enter a commit message to explain why this merge is necessary]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[版本控制]]></category>
<pubDate>Tue, 13 Feb 2018 06:46:05 +0000</pubDate> 
<guid>http://www.jackxiang.com/post/9639/</guid> 
<description>
<![CDATA[ 
	 git pull&nbsp;&nbsp;#出现：please enter a commit message to explain why this merge is necessary 请输入一个提交消息来解释为什么这个合并是必要的<br/>Merge made by the &#039;recursive&#039; strategy.<br/> ...277&#92;220&#92;347&#92;273&#92;264&#92;346&#92;211&#92;213&#92;345&#92;206&#92;214.md&quot; &#124; 23 ++++------------------<br/> 1 file changed, 4 insertions(+), 19 deletions(-)<br/><br/><br/>git 在pull或者合并分支的时候有时会遇到这个界面。请输入提交消息来解释为什么这种合并是必要的：<br/>1.按键盘字母 i 进入insert模式<br/>2.修改最上面那行黄色合并信息,可以不修改<br/>3.按键盘左上角&quot;Esc&quot;<br/>4.输入&quot;:wq&quot;,注意是冒号+wq,按回车键即可<br/><br/>当时遇到这个东西时是懵逼了，不知道如何操作，虽然我能看懂下面的话的意思，是让输入提交代码的注释。<br/>按键盘上的i键，进入输入模式，第一行的文本就是提交代码的注释，改成你想加的注释，当然也可以不改。改完后按键盘上的esc键，退出输入模式，输入&quot;:wq&quot;回车，搞定！这个东西困了我好久有木有！！！<br/><br/>来自：https://www.cnblogs.com/wei325/p/5278922.html
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post/9522/</link>
<title><![CDATA[git切换分支报错:error: pathspec origin/XXX did not match any file(s) known to git.]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[版本控制]]></category>
<pubDate>Thu, 16 Nov 2017 14:25:17 +0000</pubDate> 
<guid>http://www.jackxiang.com/post/9522/</guid> 
<description>
<![CDATA[ 
	现象：git checkout dev，出现,error: pathspec &#039;dev&#039; did not match any file(s) known to git.<br/><br/>项目上有一个分支test，使用git branch -a看不到该远程分支，直接使用命令git checkout test报错如下：<br/><br/>error: pathspec &#039;origin/test&#039; did not match any file(s) known to git.<br/>解决方法： <br/>1、执行命令git fetch取回所有分支的更新<br/>2、执行git branch -a可以看到test分支（已经更新分支信息）<br/>3、切换分支git checkout test<br/><br/>From:http://blog.csdn.net/lissdy/article/details/50291995
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post/9519/</link>
<title><![CDATA[[实践OK]Git 2.x 中git push时遇到 push.default 警告的解决方法]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[版本控制]]></category>
<pubDate>Tue, 14 Nov 2017 12:01:26 +0000</pubDate> 
<guid>http://www.jackxiang.com/post/9519/</guid> 
<description>
<![CDATA[ 
	git version 2.7.4在提交时出现 push.default 警告问题。<br/>两步解决：<br/>步骤一：git config --global push.default simple<br/>步骤二：git push -u origin master&nbsp;&nbsp;#第一次,或：git push -u origin devel<br/>步骤三：后再直接执行 git push 就可以了。<br/><br/><br/>新建立分支后及时上面设置还是会报错怎么办？如下：<br/>#git push<br/>fatal: 当前分支 release1 没有对应的上游分支。<br/>为推送当前分支并建立与远程上游的跟踪，使用<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;git push --set-upstream origin release1<br/><br/>git config -l&#124;grep simple<br/>push.default=simple<br/><br/>按它提示的设置一下呢?就好了，如下：<br/><br/>git push --set-upstream origin release1<br/>Total 0 (delta 0), reused 0 (delta 0)<br/>remote: <br/>remote: To create a merge request for release1, visit:<br/>.....<br/>remote: <br/>To git@gitlab.xxx.com.cn:devel/iot.lewo.com.git<br/> * [new branch]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;release1 -&gt; release1<br/>分支 release1 设置为跟踪来自 origin 的远程分支 release1。<br/><br/>在merge后，其并没有啥状态不一样的，因为没有冲突啥的，Merge后，以及提交后的一个对比：<br/>Merge后：<br/>#git status<br/>位于分支 release1<br/>无文件要提交，干净的工作区<br/>提交Merge到GitServer后（git push --set-upstream origin release1）：<br/>#git status<br/>位于分支 release1<br/>您的分支与上游分支 &#039;origin/release1&#039; 一致。<br/>无文件要提交，干净的工作区<br/><br/>=====================实践如下======================<br/><textarea name="code" class="php" rows="15" cols="100">
#git config --global push.default simple
#git push
fatal: 当前分支 devel 没有对应的上游分支。
为推送当前分支并建立与远程上游的跟踪，使用

git push --set-upstream origin devel

#git push -u origin devel
对象计数中: 3, 完成.
压缩对象中: 100% (3/3), 完成.
写入对象中: 100% (3/3), 355 bytes &#124; 0 bytes/s, 完成.
Total 3 (delta 2), reused 0 (delta 0)
remote: 
remote: To create a merge request for devel, visit:
remote:&nbsp;&nbsp; http://gitlab.xxx.com.cn/devel/iot.lewo.com/merge_requests/new?merge_request%5Bsource_branch%5D=devel
remote: 
To git@gitlab.xxx.com.cn:devel/iot.lewo.com.git
 * [new branch]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;devel -&gt; devel
分支 devel 设置为跟踪来自 origin 的远程分支 devel。
第二次，不用再写那个origin devel了：
#git commit -m&quot;添加一个文件进入Devel&quot;&nbsp;&nbsp;README.md 
[devel ee8bd06] 添加一个文件进入Devel
 1 file changed, 2 insertions(+), 2 deletions(-)

#git push 
对象计数中: 3, 完成.
压缩对象中: 100% (3/3), 完成.
写入对象中: 100% (3/3), 361 bytes &#124; 0 bytes/s, 完成.
Total 3 (delta 2), reused 0 (delta 0)
remote: 
remote: To create a merge request for devel, visit:
remote:&nbsp;&nbsp; http://gitlab.xxx.com.cn/devel/iot.lewo.com/merge_requests/new?merge_request%5Bsource_branch%5D=devel
remote: 
To git@gitlab.xxx.com.cn:devel/iot.lewo.com.git
&nbsp;&nbsp; 559a6b3..ee8bd06&nbsp;&nbsp;devel -&gt; devel

</textarea><br/><br/>git提交时，出现问题如下：<br/>#git push origin/devel<br/>warning: push.default 尚未设置，它的默认值在 Git 2.0 已从 &#039;matching&#039;<br/>变更为 &#039;simple&#039;。若要不再显示本信息并保持传统习惯，进行如下设置：<br/><br/>&nbsp;&nbsp;git config --global push.default matching<br/><br/>若要不再显示本信息并从现在开始采用新的使用习惯，设置：<br/><br/>&nbsp;&nbsp;git config --global push.default simple<br/><br/>当 push.default 设置为 &#039;matching&#039; 后，git 将推送和远程同名的所有<br/>本地分支。<br/><br/>从 Git 2.0 开始，Git 默认采用更为保守的 &#039;simple&#039; 模式，只推送当前<br/>分支到远程关联的同名分支，即 &#039;git push&#039; 推送当前分支。<br/><br/>参见 &#039;git help config&#039; 并查找 &#039;push.default&#039; 以获取更多信息。<br/>（&#039;simple&#039; 模式由 Git 1.7.11 版本引入。如果您有时要使用老版本的 Git，<br/>为保持兼容，请用 &#039;current&#039; 代替 &#039;simple&#039;）<br/><br/>fatal: &#039;origin/devel&#039; does not appear to be a git repository<br/>fatal: Could not read from remote repository.<br/><br/>Please make sure you have the correct access rights<br/>and the repository exists.
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post/9516/</link>
<title><![CDATA[git push 的 -u 参数具体适合含义？]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[版本控制]]></category>
<pubDate>Tue, 07 Nov 2017 14:18:36 +0000</pubDate> 
<guid>http://www.jackxiang.com/post/9516/</guid> 
<description>
<![CDATA[ 
	来自：https://www.zhihu.com/question/20019419<br/>The -u tells Git to remember the parameters, so that next time we can simply run git push and Git will know what to do.相当于第一次串门的时候你登了个记办了个vip。。以后再来就知道是你来了。不用脱裤子搜身了<br/><br/>链接：https://www.zhihu.com/question/20019419/answer/80590142<br/><br/>
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post/9506/</link>
<title><![CDATA[git fatal: index file smaller than expected]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[版本控制]]></category>
<pubDate>Wed, 25 Oct 2017 10:12:43 +0000</pubDate> 
<guid>http://www.jackxiang.com/post/9506/</guid> 
<description>
<![CDATA[ 
	由于git的index文件出错。<br/><br/>需要删除.git/index文件，<br/><br/>然后运行git reset，重新生成index文件。<br/>git reset还可以删除已经commit，但未push上去的信息。<br/><br/>From:https://my.oschina.net/dyxp/blog/380642
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post/9476/</link>
<title><![CDATA[[实践OK]无论在root用户下面依然是xiangdong用户提交git，git push均以xiangdong用户提交小工具，防止误以root用户提交。周边知识之C语言getcwd()函数：取得当前的工作目录，获取被执行程序的绝对目录,]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[版本控制]]></category>
<pubDate>Sun, 01 Oct 2017 13:57:25 +0000</pubDate> 
<guid>http://www.jackxiang.com/post/9476/</guid> 
<description>
<![CDATA[ 
	背景：Git分不同角色在提交时，root提交时是administrator（Crontab用来Pull一些Ansible脚本到本地）, 而xiangdong提交时是xiangdong，往往容易出现一个问题是不小心给root了，这块一是xiangdong上去有时权限不够可能切换为root了，另一个是登录时可能就是Root用户，一提交就成Admin了。鉴于此，自己整个C代码实现提交判断，这样接管了git push，从而对粗心的我来讲起到一个助理的作用。<br/><br/>一、搞这玩意儿的原因：<br/>root情况：<br/><textarea name="code" class="php" rows="15" cols="100">
git config -l
user.name=Administrator
user.email=admin@example.com
</textarea><br/>xiangdong:<br/><textarea name="code" class="php" rows="15" cols="100">
git config -l
user.name=xiangdong
user.email=xiangdong@justwinit.cn
core.autocrlf=input
</textarea><br/>解决一个无论是root还是xiangdong的环境下，只需要执行下面我们搞的这个c语言生成的二进制文件就能一直只以向东的用户进行提交git，看起来扯淡，但还是有点用的，敲啥呢： gitpush ，和git push只是没有那个空格了。经实践证明是可行的，如下：<br/><br/><br/>二、生产这个玩意的过程：<br/>源码及Makefile和生成的二进制文件路径：<br/><textarea name="code" class="php" rows="15" cols="100">
#tree -L 2 ../../gitpush/
../../gitpush/
├── bin
│   └── gitpush
└── src
&nbsp;&nbsp;&nbsp;&nbsp;├── gitpush.c
&nbsp;&nbsp;&nbsp;&nbsp;└── Makefile
</textarea><br/><br/>Makefile文件内容：<br/>cat Makefile <br/><textarea name="code" class="php" rows="15" cols="100">
gitpush:gitpush.c
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gcc -g -o&nbsp;&nbsp;gitpush -Wall gitpush.c
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mv gitpush ../bin
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;chmod a+x ../bin/gitpush
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cp -rf /usr/local/gitpush/src/gitpush.sh /etc/profile.d/gitpush.sh
clean:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rm -rf gitpush&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rm -rf /etc/profile.d/gitpush.sh
</textarea><br/>源代码：cat gitpush.c <br/><textarea name="code" class="php" rows="15" cols="100">
#include &lt;stdio.h&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
#include &lt;string.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;sys/types.h&gt;
#include &lt;unistd.h&gt;
#include &lt;stdarg.h&gt;
#include &lt;sys/types.h&gt;
#include &lt;pwd.h&gt;
int main()
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char curpath[80];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char forbidname[]=&quot;root&quot;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char whoami[80];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char command[36000];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FILE *pPipe;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char psBuffer[36000];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;struct passwd *pwd;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pwd = getpwuid(getuid());
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//printf(&quot;当前登陆的用户名为：%s&#92;n&quot;, pwd-&gt;pw_name);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strcpy(whoami,pwd-&gt;pw_name);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getcwd(curpath, sizeof(curpath));
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//printf(&quot;current working directory : %s&#92;n&quot;, curpath);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//printf(&quot;The UID is %d &#92;n&quot;, getuid());
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//strcpy(whoami,getlogin()); #要是先xiangdong登录，再sudo su -成root，值还是向东。
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//printf(&quot;The login name is %s&#92;n&quot;, getlogin());
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//printf(&quot;The forbidlogin name is %s&#92;n&quot;, forbidname);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(0 == strcmp(forbidname,whoami))&#123;//root，得提示一下换角色再Push
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;提醒：请小心，现在正在Root环境下面，立即切换到xiangdong用户并作提交。&#92;n&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;snprintf(command,sizeof(command),&quot;/usr/bin/sudo -i -u xiangdong -H cd %s &amp;&amp; git push&quot;,curpath);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;else&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;snprintf(command,sizeof(command),&quot;cd %s &amp;&amp; git push&quot;,curpath);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;执行:%s&#92;n&quot;,command);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if( (pPipe = popen( command, &quot;r&quot; )) == NULL )&#123;//执行脚本
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;Excute Command Faild :%s&quot;,command);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit( 1 );
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while(!feof(pPipe))/* Read pipe until end of file. */
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(fgets(psBuffer, sizeof(psBuffer), pPipe) != NULL)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;%s&quot;,psBuffer);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pclose(pPipe);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 1;
&#125;
</textarea><br/><br/><br/>最后，PATH路径：<br/>cat /etc/profile.d/gitpush.sh <br/><textarea name="code" class="php" rows="15" cols="100">
export PATH=$PATH:/usr/local/gitpush/bin
</textarea><br/><br/>三、验证步骤阶段：<br/>root下执行情况：<br/>#gitpush<br/>#gitpush<br/>当前登陆的用户名为：root<br/>current working directory : /home/xiangdong/shell<br/>The UID is 0 <br/>The login name is xiangdong<br/>The forbidlogin name is root<br/>请小心，你现在正在Root环境下面，不过没关系，我给你切换到xiangdong用户并作提交。执行git push命令：/usr/bin/sudo -i -u xiangdong -H cd /home/xiangdong/shell &amp;&amp; git push<br/>Counting objects: 4, done.<br/>Delta compression using up to 4 threads.<br/>Compressing objects: 100% (2/2), done.<br/>Writing objects: 100% (3/3), 288 bytes, done.<br/>Total 3 (delta 1), reused 1 (delta 0)<br/>To git@gitlab.qr.justwinit.net:levooops/shell.git<br/>&nbsp;&nbsp; bd83c51..b400811&nbsp;&nbsp;master -&gt; master<br/><br/>xiangdong下面执行情况：<br/>$gitpush<br/>执行:cd /home/xiangdong/shell &amp;&amp; git push<br/>Counting objects: 5, done.<br/>Delta compression using up to 4 threads.<br/>Compressing objects: 100% (2/2), done.<br/>Writing objects: 100% (3/3), 277 bytes, done.<br/>Total 3 (delta 1), reused 0 (delta 0)<br/>To git@gitlab.qr.justwinit.net:levooops/shell.git<br/>&nbsp;&nbsp; b400811..0b19550&nbsp;&nbsp;master -&gt; master<br/><br/>成功Log:<br/>$git log<br/>commit 0b195507efa6278774d4f500a7086003d6744684<br/>Author: xiangdong &lt;xiangdong@justwinit.cn&gt;<br/>Date:&nbsp;&nbsp; Sun Oct 1 23:15:32 2017 +0800<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;加上README.md<br/><br/>commit b40081190bf020d49375a4117a181f00ea0a2503<br/>Author: xiangdong &lt;xiangdong@justwinit.cn&gt;<br/>Date:&nbsp;&nbsp; Sun Oct 1 23:09:58 2017 +0800<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;加上README.md<br/><br/>================================================================================<br/>附录：<br/>为什么 sudo cd 会报错 command not found:<br/>https://www.starduster.me/2015/09/12/why-command-not-found-when-sudo-cd/<br/><br/>相关函数：get_current_dir_name, getwd, chdir<br/>头文件：#include &lt;unistd.h&gt;<br/>定义函数：char * getcwd(char * buf, size_t size);<br/>函数说明：getcwd()会将当前的工作目录绝对路径复制到参数buf 所指的内存空间，参数size 为buf 的空间大小。<br/>注：<br/>1、在调用此函数时，buf 所指的内存空间要足够大。若工作目录绝对路径的字符串长度超过参数size 大小，则返回NULL，errno 的值则为ERANGE。<br/>2、倘若参数buf 为NULL，getcwd()会依参数size 的大小自动配置内存(使用malloc())，如果参数size 也为0，则getcwd()会依工作目录绝对路径的字符串程度来决定所配置的内存大小，进程可以在使用完次字符串后利用free()来释放此空间。<br/><br/>返回值：执行成功则将结果复制到参数buf 所指的内存空间, 或是返回自动配置的字符串指针. 失败返回NULL,错误代码存于errno.<br/><br/>范例<br/><textarea name="code" class="php" rows="15" cols="100">
#include &lt;unistd.h&gt;
main()
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;char buf[80];
&nbsp;&nbsp;&nbsp;&nbsp;getcwd(buf, sizeof(buf));
&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;current working directory : %s&#92;n&quot;, buf);
&#125;
</textarea><br/><br/>执行：<br/>current working directory :/tmp<br/><br/>cat test_processname.cpp<br/><textarea name="code" class="php" rows="15" cols="100">
#include &lt;limits.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;unistd.h&gt;
size_t get_executable_path( char* processdir,char* processname, size_t len)
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char* path_end;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(readlink(&quot;/proc/self/exe&quot;, processdir,len) &lt;=0)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return -1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;path_end = strrchr(processdir,&nbsp;&nbsp;&#039;/&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(path_end == NULL)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return -1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;++path_end;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strcpy(processname, path_end);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*path_end = &#039;&#92;0&#039;;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return (size_t)(path_end - processdir);
&#125;
int main()
&#123;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char path[PATH_MAX];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char processname[1024];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;get_executable_path(path, processname, sizeof(path));
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;directory:%s&#92;nprocessname:%s&#92;n&quot;,path,processname);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;char buf[80];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getcwd(buf, sizeof(buf));
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;current working directory : %s&#92;n&quot;, buf);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;The UID is %d &#92;n&quot;, getuid());
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(&quot;The login name is %s&#92;n&quot;, getlogin());
&#125;
</textarea><br/><br/><br/>g++ test_processname.cpp -o gitpush<br/>mv /tmp/gp /usr/local/gitpush/gitpush <br/><br/>cat /etc/profile.d/gp.sh <br/>export PATH=$PATH:/usr/local/gitpush<br/><br/>#gp<br/>directory:/usr/local/gitpush/<br/>processname:gp<br/>current working directory : /root<br/><br/><br/>./gitpush<br/>directory:/tmp/<br/>processname:gitpush<br/>current working directory : /tmp<br/>The UID is 0 <br/>The login name is xiangdong
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post/9471/</link>
<title><![CDATA[[实践OK]The following untracked working tree files would be overwritten by merge]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[版本控制]]></category>
<pubDate>Tue, 26 Sep 2017 09:34:29 +0000</pubDate> 
<guid>http://www.jackxiang.com/post/9471/</guid> 
<description>
<![CDATA[ 
	我的问题：git pull<br/>error: Untracked working tree file &#039;playbook/ml.qr.justwinit.cn/process.yml&#039; would be overwritten by merge.&nbsp;&nbsp;Aborting<br/>git fetch --all &amp;&amp; git reset --hard origin/master<br/>一、解决办法：<br/><textarea name="code" class="php" rows="15" cols="100">
$git fetch --all &amp;&amp; git reset --hard origin/master
Fetching origin
HEAD is now at d33031a edit dns playbook
</textarea><br/><br/>二、再git pull就没有问题了，当然，你的改动也被回退了，得先备份再做这个操作：<br/>$git pull<br/>Already up-to-date.<br/><br/>三、重新将文件放进去，再进行commit后push，没毛病：<br/>git commit -m&quot;xxx&quot; ishow.justwinit.cn.conf.j2 <br/>git push<br/>Counting objects: 11, done.<br/>Delta compression using up to 4 threads.<br/>Compressing objects: 100% (6/6), done.<br/>Writing objects: 100% (6/6), 815 bytes, done.<br/>Total 6 (delta 3), reused 0 (delta 0)<br/>To git@gitlab.qr.cntv.net:irdcops/ansible.git<br/>&nbsp;&nbsp; d33031a..eb4ad86&nbsp;&nbsp;master -&gt; master<br/>来自：https://www.codecaptain.io/reference/git/the-following-untracked-working-tree-files-would-be-overwritten-by-merge
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post/9468/</link>
<title><![CDATA[git孤立分支的使用情况是什么？Git 入怼之独立分支。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[版本控制]]></category>
<pubDate>Mon, 25 Sep 2017 03:26:34 +0000</pubDate> 
<guid>http://www.jackxiang.com/post/9468/</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;&nbsp;&nbsp; git中可以承载多个DAGs Repo一样的情况 git checkout --orphan命令。 git的常见用例是此功能是保持独立的文档和github的gh pages孤立的分支branch来创建一个静态网站。<br/>孤立分支特征：<br/>1）master好孤立分支是一个.git仓库里面的两颗独立的数，也就是说他俩没法合并。<br/>2）master默认是保护的，建议把master 干掉，默认保护master的变为master.andorid,类似这样的。<br/>3）孤立分支里面再建立分支，他们之间和常规分支一样的，没有区别。<br/>一）其他用例孤立的分支有哪些？<br/>可能的用法是用于将多个系统信息库组合成一个。 是一些例子：<br/>Combining多个git库?<br/>在这些情况下你必须在同一个档案库中的两个独立DAG之前合并到一个统一的目录树。 因此在长期使用，但这不是尽可能多的操作将暂时通过的状态使用单独的DAG所在的系统信息库中。<br/><br/>二）来自操作手册：<br/>###创建孤立分支<br/>&nbsp;&nbsp;&nbsp;&nbsp;git version 1.7.2+<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;# 创建<br/>&nbsp;&nbsp;&nbsp;&nbsp;git checkout --orphan &lt;newbranch&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;# 删除无用文件<br/>&nbsp;&nbsp;&nbsp;&nbsp;git rm -rf .<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;# 提交“空”内容<br/>&nbsp;&nbsp;&nbsp;&nbsp;git commit --allow-empty -m &quot;[empty] initial commit&quot;<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;# 把新创建的本地分支，推送到远端仓库，保持跟踪<br/>&nbsp;&nbsp;&nbsp;&nbsp;git push -u origin &lt;newbranch&gt;<br/><br/><br/>三）实践建一个“孤立”的空分支操作如下，命令来地址（https://ihower.tw/blog/archives/5691）：<br/><textarea name="code" class="php" rows="15" cols="100">
#git clone git@gitlab.XXXXXX.com.cn:devops/docs.git
正克隆到 &#039;docs&#039;...
remote: Counting objects: 170, done.
remote: Compressing objects: 100% (152/152), done.
remote: Total 170 (delta 20), reused 160 (delta 16)
接收对象中: 100% (170/170), 38.50 MiB &#124; 138.00 KiB/s, 完成.
处理 delta 中: 100% (20/20), 完成.
检查连接... 完成

#cd docs/

#git checkout --orphan newbranch
切换到一个新分支 &#039;newbranch&#039;

#git status
位于分支 newbranch

#git rm -rf .

#git add .&nbsp;&nbsp; #cp -a /data/www/xx.xxxx.xxx/* ./&nbsp;&nbsp;#拷贝代码到当前位置。~/ansible   bjcc

#ls

#git commit -m &#039;create new branch&#039;
位于分支 newbranch
初始提交
无文件要提交


#git push
fatal: 当前分支 newbranch 没有对应的上游分支。
为推送当前分支并建立与远程上游的跟踪，使用

&nbsp;&nbsp;&nbsp;&nbsp;git push --set-upstream origin newbranch

#git push --set-upstream origin newbranch
error: src refspec newbranch does not match any.
error: 无法推送一些引用到 &#039;git@gitlab.XXXXXX.com.cn:devops/docs.git&#039;


vi&nbsp;&nbsp;README.md

#git commit -m&quot;测试一下刚建立的孤立分支&quot;
[newbranch（根提交） 754a735] 测试一下刚建立的孤立分支
 1 file changed, 1 insertion(+)
 create mode 100644 README.md


 #git push --set-upstream origin newbranch
对象计数中: 3, 完成.
写入对象中: 100% (3/3), 256 bytes &#124; 0 bytes/s, 完成.
Total 3 (delta 0), reused 0 (delta 0)
remote: 
remote: To create a merge request for newbranch, visit:
remote:&nbsp;&nbsp; http://gitlab.XXXXXX.com.cn/devops/docs/merge_requests/new?merge_request%5Bsource_branch%5D=newbranch
remote: 
To git@gitlab.XXXXXX.com.cn:devops/docs.git
 * [new branch]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;newbranch -&gt; newbranch
分支 newbranch 设置为跟踪来自 origin 的远程分支 newbranch。
</textarea><br/><br/>在Gitlab的Web界面里测试一下孤立分支：<br/>newbranch&nbsp;&nbsp; Merge RequestCompare Select Archive Format<br/> 754a735a · 测试一下刚建立的孤立分支&nbsp;&nbsp;· 2 minutes ago<br/><br/>参考：https://ooso.net/archives/636
]]>
</description>
</item>
</channel>
</rss>