TIPS
<span style="color: rgb(51, 51, 51); font-family: Helvetica, Arial, sans-serif; font-size: 16.003px; background-color: rgb(218, 231, 255);">像錯誤修復或功能添加之類不同含義的更改,要盡量分開來提交。這樣可以方便事後從歷史記錄裡找出特定的修改內容。</span>
<p class="Mg-b10" style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; color: rgb(51, 51, 51); font-size: 16.003px; line-height: 1.7; font-family: Helvetica, Arial, sans-serif;">提交訊息是查看其他人提交的修改內容或自己檢查歷史記錄時重要的資料。所以要用心填寫讓人容易理解的提交訊息。</p><p class="Mg-b10" style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; color: rgb(51, 51, 51); font-size: 16.003px; line-height: 1.7; font-family: Helvetica, Arial, sans-serif;">Git的標準提交訊息:</p><pre class="Mg-b10" style="font-family: "Bitstream Vera Sans Mono", Courier, monospace; line-height: 1.4; margin-top: 0px; padding: 10px 15px; border: 1px solid rgb(153, 153, 153); vertical-align: baseline; font-size: 13px; white-space: pre-wrap; word-wrap: break-word; background-color: rgb(238, 238, 238); border-radius: 2px; color: rgb(25, 25, 25); margin-bottom: 10px !important;">第1行:提交時修改內容的摘要
第2行:空行
第3行以後:修改的理由</pre><p style="margin: 0px 0px 1em; padding: 0px; border: 0px; vertical-align: baseline; color: rgb(51, 51, 51); font-size: 16.003px; line-height: 1.7; font-family: Helvetica, Arial, sans-serif;">建議以這種形式填寫提交訊息</p>
<ol style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 0px 0px 0px 2em; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px;"><li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased;">返回到原先已经发布到生产服务器上的分支。</li><li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased;">为这次紧急修补建立一个新分支,并在其中修复问题。</li><li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased;">通过测试后,回到生产服务器所在的分支,将修补分支合并进来,然后再推送到生产服务器上。</li><li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased;">切换到之前实现新需求的分支,继续工作。</li></ol>
本地数据库
<span style="color: rgb(51, 51, 51); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px;">在 Git 内都只有三种状态:已提交(committed),已修改(modified)和已暂存(staged)。已提交表示该文件已经被安全地保存在本地数据库中了;已修改表示修改了某个文件,但还没有提交保存;已暂存表示把已修改的文件放在下次提交时要保存的清单中。</span>
<p style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px;">第一行告诉 Git 忽略所有以 <code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin: 0px; background-color: rgb(247, 247, 247); border-radius: 3px;">.o</code> 或 <code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin: 0px; background-color: rgb(247, 247, 247); border-radius: 3px;">.a</code> 结尾的文件。一般这类对象文件和存档文件都是编译过程中出现的,我们用不着跟踪它们的版本。第二行告诉 Git 忽略所有以波浪符(<code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin: 0px; background-color: rgb(247, 247, 247); border-radius: 3px;">~</code>)结尾的文件,许多文本编辑软件(比如 Emacs)都用这样的文件名保存副本。此外,你可能还需要忽略 <code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin: 0px; background-color: rgb(247, 247, 247); border-radius: 3px;">log</code>,<code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin: 0px; background-color: rgb(247, 247, 247); border-radius: 3px;">tmp</code> 或者 <code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin: 0px; background-color: rgb(247, 247, 247); border-radius: 3px;">pid</code> 目录,以及自动生成的文档等等。要养成一开始就设置好 <code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin: 0px; background-color: rgb(247, 247, 247); border-radius: 3px;">.gitignore</code> 文件的习惯,以免将来误提交这类无用的文件。</p><p style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px;">文件 <code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin: 0px; background-color: rgb(247, 247, 247); border-radius: 3px;">.gitignore</code> 的格式规范如下:</p><ul style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; padding: 0px 0px 0px 2em; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px;"><li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased;">所有空行或者以注释符号 <code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin: 0px; background-color: rgb(247, 247, 247); border-radius: 3px;">#</code> 开头的行都会被 Git 忽略。</li><li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased;">可以使用标准的 glob 模式匹配。</li><li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased;">匹配模式最后跟反斜杠(<code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin: 0px; background-color: rgb(247, 247, 247); border-radius: 3px;">/</code>)说明要忽略的是目录。</li><li style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased;">要忽略指定模式以外的文件或目录,可以在模式前加上惊叹号(<code style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; text-size-adjust: none; -webkit-font-smoothing: antialiased; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px; padding: 0.2em 0px; margin: 0px; background-color: rgb(247, 247, 247); border-radius: 3px;">!</code>)取反。</li></ul>
子主题