socialforge/app/views/git_usage/ch_usage.html.erb

242 lines
7.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- added by baiyu -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
body table tr th {
font-size: 24px;
color: #666;
}
body table tr td {
color: #333;
}
body table tr td {
color: #333;
font-size: 18px;
font-family: "Comic Sans MS", cursive;
}
body table tr td span {
color: #039;
}
body p {
font-size: 18px;
color: #009;
}
body table tr td p {
color: #333;
}
</style>
</head>
<body><table width="896" border="0">
<tr>
<th width="890" align="center" valign="middle"> Git使用说明</th>
</tr>
</table>
<table width="892" border="0">
<tr>
<td width="886">我们将使用 <span>git</span> 这个分布式版本控制系统来提交代码,下面就来介绍一下代码的提交方法。</td>
</tr>
</table>
<table width="200" border="0">
<tr>
<td>&nbsp;</td>
</tr>
</table>
<table width="456" border="0">
<tr>
<td width="450"><p ><span>Step1</span> </p></td>
</tr>
<tr>
<td><p >打开终端,输入如下命令:</p></td>
</tr>
<tr>
<td align="center"><p ><span>$git&nbsp;config&nbsp;--global&nbsp;user.name&nbsp;&#8220;your_name&#8221; </span></p>
<p></p>
<p ><span>$git&nbsp;config&nbsp;--global&nbsp;user.email&nbsp;&#8220;your_email&#8221;</span></p></td>
</tr>
</table>
<table width="900" border="0">
<tr>
<td><p >用户名和email是用来设置自己的用户名和联系方式的user.name和user.email必须填写这些将在版本库提交时用到。 </p></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><p >Tips </p></td>
</tr>
<tr>
<td><p >在碰到不熟悉的命令时,可以通过&nbsp;<span>git&nbsp;help</span>命令查看git的用户手册命令如下 </p></td>
</tr>
</table>
<table width="297" border="0">
<tr>
<td width="291" align="center"><p ><span>$git&nbsp;help&nbsp;&lt;command&gt;</span> </p></td>
</tr>
</table>
<table width="899" border="0">
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><p ><span>Step2:</span> </p></td>
</tr>
<tr>
<td><p >创建版本库(两种途径) </p></td>
</tr>
</table>
<table width="899" border="0">
<tr>
<td><p >1从远程服务器上克隆一个已存在的版本库到本地 </p></td>
</tr>
</table>
<table width="522" border="0">
<tr>
<td width="516" align="center"><p ><span>$git&nbsp;clone&nbsp;http://user_name@domain/repo_path.git</span> </p></td>
</tr>
</table>
<table width="898" border="0">
<tr>
<td width="892"><p >其中domain是服务器的域名(在trustie系统域名222.247.54.100)repo_path.git是版本库在服务器的相对路径(这个地址在trustie系统中会给出) </p></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><p >2在本地初始化一个版本库比如将版本库命名为&#8220;DEMO&#8221;,使用名为/path/to/my/workspace的目录作为个人的工作区根目录进入该目录后执行<span>git&nbsp;init</span>创建版本库。 </p></td>
</tr>
</table>
<table width="327" border="0" align="left">
<tr>
<td width="321"><p ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$cd&nbsp;/path/to/my/workspace </span></p></td>
</tr>
<tr>
<td><p ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$mkdir&nbsp;demo</span> </p></td>
</tr>
<tr>
<td><p ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$cd&nbsp;demo </span></p></td>
</tr>
<tr>
<td><p ><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$git&nbsp;init&nbsp; </span></p></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<table width="898" border="0">
<tr>
<td><p >完成上述操作后,可以看到<span>git&nbsp;init</span>命令在工作区创建了隐藏目录&nbsp;<span>.git</span>。这个隐藏的&nbsp;.git目录就是git版本库repository。 </p></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><p ><span>Step3</span> </p></td>
</tr>
<tr>
<td><p >提交文件到本地仓库: </p></td>
</tr>
</table>
<table width="258" border="0">
<tr>
<td width="252" align="center"><p ><span>$git&nbsp;add&nbsp;file1&nbsp;file2&nbsp; </span></p></td>
</tr>
</table>
<table width="897" border="0">
<tr>
<td><p >files是做了修改的文件多个文件使用空格隔开。 </p></td>
</tr>
</table>
<table width="386" border="0">
<tr>
<td width="380" align="center"><p ><span>$git&nbsp;commit&nbsp;&#8211;m&nbsp;&quot;commit&nbsp;message&quot;&nbsp; </span></p></td>
</tr>
</table>
<table width="897" border="0">
<tr>
<td width="891"><p >通过<span>-m</span>参数设置提交说明为&#8220;<span>commit&nbsp;message</span>&#8221;Git强制性的要求在提交过程中需要输入提交说明可以使用<span>git&nbsp;log</span>命令来查看提交日志。 </p></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><p ><span>Step4</span> </p></td>
</tr>
<tr>
<td><p >将本地分支推送到远程仓库: </p></td>
</tr>
<tr>
<td><p >上述操作仅仅是在本地建立了一个git版本库为了协同工作我们可以将其推送到远程服务器。 </p></td>
</tr>
</table>
<table width="610" border="0">
<tr>
<td width="604" align="center"><p ><span>$git&nbsp;remote&nbsp;add&nbsp;origin&nbsp;http://user_name@domain/repo_path.git&nbsp;</span> </p></td>
</tr>
</table>
<table width="896" border="0">
<tr>
<td><p >远程库别名为<span>origin</span> </p></td>
</tr>
</table>
<table width="292" border="0">
<tr>
<td width="328" align="center"><p ><span>$git&nbsp;push&nbsp;origin&nbsp;master&nbsp; </span></p></td>
</tr>
</table>
<table width="895" border="0">
<tr>
<td width="485"><p >将本地的master分支推送到origin的master分支 </p></td>
</tr>
</table>
<table width="896" border="0">
<tr>
<td width="900">&nbsp;</td>
</tr>
</table>
<table width="894" border="0">
<tr>
<td><p ><span>Step5</span> </p></td>
</tr>
<tr>
<td><p >将远程仓库的分支更新到本地: </p></td>
</tr>
<tr>
<td><p >当项目小组有成员将其自己的代码推送到服务器,我们可以使用<span>git&nbsp;pull</span>&nbsp;(或者<span>git&nbsp;fetch</span>)获取更新后的代码。</p></td>
</tr>
</table>
<table width="279" border="0">
<tr>
<td width="273" align="center"><p ><span>$git&nbsp;pull&nbsp;origin&nbsp;master </span></p></td>
</tr>
</table>
<table width="893" border="0">
<tr>
<td><p >将远程库origin的master分支更新到本地的master分支 </p></td>
</tr>
</table>
<table width="891" border="0">
<tr>
<td>&nbsp;</td>
</tr>
</table>
<table width="831" border="0">
<tr>
<td width="825" align="right">——Trustie团队</td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
<!-- end -->