242 lines
7.2 KiB
Plaintext
242 lines
7.2 KiB
Plaintext
|
<!-- 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> </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 config --global user.name “your_name” </span></p>
|
|||
|
<p></p>
|
|||
|
<p ><span>$git config --global user.email “your_email”</span></p></td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
<table width="900" border="0">
|
|||
|
<tr>
|
|||
|
<td><p >用户名和email是用来设置自己的用户名和联系方式的(user.name和user.email必须填写,这些将在版本库提交时用到)。 </p></td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td><p >Tips: </p></td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td><p >在碰到不熟悉的命令时,可以通过 <span>git help</span>命令查看git的用户手册,命令如下: </p></td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
<table width="297" border="0">
|
|||
|
<tr>
|
|||
|
<td width="291" align="center"><p ><span>$git help <command></span> </p></td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
<table width="899" border="0">
|
|||
|
<tr>
|
|||
|
<td> </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 clone 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> </td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td><p >(2)在本地初始化一个版本库,比如将版本库命名为“DEMO”,使用名为/path/to/my/workspace的目录作为个人的工作区根目录,进入该目录后,执行<span>git init</span>创建版本库。 </p></td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
<table width="327" border="0" align="left">
|
|||
|
<tr>
|
|||
|
<td width="321"><p ><span> $cd /path/to/my/workspace </span></p></td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td><p ><span> $mkdir demo</span> </p></td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td><p ><span> $cd demo </span></p></td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td><p ><span> $git init </span></p></td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
<p> </p>
|
|||
|
<p> </p>
|
|||
|
<table width="898" border="0">
|
|||
|
<tr>
|
|||
|
<td><p >完成上述操作后,可以看到<span>git init</span>命令在工作区创建了隐藏目录 <span>.git</span>。这个隐藏的 .git目录就是git版本库(repository)。 </p></td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </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 add file1 file2 </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 commit –m "commit message" </span></p></td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
<table width="897" border="0">
|
|||
|
<tr>
|
|||
|
<td width="891"><p >通过<span>-m</span>参数设置提交说明为“<span>commit message</span>”,Git强制性的要求在提交过程中需要输入提交说明,可以使用<span>git log</span>命令来查看提交日志。 </p></td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td> </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 remote add origin http://user_name@domain/repo_path.git </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 push origin master </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"> </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 pull</span> (或者<span>git fetch</span>)获取更新后的代码。</p></td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
<table width="279" border="0">
|
|||
|
<tr>
|
|||
|
<td width="273" align="center"><p ><span>$git pull origin 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> </td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
<table width="831" border="0">
|
|||
|
<tr>
|
|||
|
<td width="825" align="right">——Trustie团队</td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
<p> </p>
|
|||
|
<p> </p>
|
|||
|
<p> </p>
|
|||
|
<p> </p>
|
|||
|
<p> </p>
|
|||
|
</body>
|
|||
|
</html>
|
|||
|
|
|||
|
<!-- end -->
|