上传本地代码及更新代码到GitHub教程
<h1 id="上传本地代码及更新代码到github教程">上传本地代码及更新代码到GitHub教程</h1><h2 id="上传本地代码">上传本地代码</h2>
<h2 id="第一步去github上创建自己的repository创建页面如下图所示">第一步:去github上创建自己的Repository,创建页面如下图所示:</h2>
<p><img src="https://images2017.cnblogs.com/blog/1249529/201710/1249529-20171025111734035-171097772.png"></p>
<h2 id="红框为新建的仓库的https地址">红框为新建的仓库的https地址</h2>
<p><img src="https://images2017.cnblogs.com/blog/1249529/201710/1249529-20171025111740348-1861677831.png"></p>
<h2 id="第二步">第二步:</h2>
<pre><code class="hljs ruby">echo <span class="hljs-string">"# Test" <span class="hljs-meta">>> README.md</span></span></code></pre>
<h2 id="第三步建立git仓库">第三步:建立git仓库</h2>
<pre><code class="hljs nginx"><span class="hljs-attribute">git init
</span></code></pre>
<h2 id="第四步将项目的所有文件添加到仓库中">第四步:将项目的所有文件添加到仓库中</h2>
<pre><code class="hljs dockerfile">git <span class="hljs-keyword">add<span class="bash"> .
</span></span></code></pre>
<h2 id="第五步">第五步:</h2>
<pre><code class="hljs dockerfile">git <span class="hljs-keyword">add<span class="bash"> README.md
</span></span></code></pre>
<h2 id="第六步提交到仓库">第六步:提交到仓库</h2>
<pre><code class="hljs nginx"><span class="hljs-attribute">git commit -m <span class="hljs-string">"注释语句"
</span></span></code></pre>
<h2 id="第七步将本地的仓库关联到github后面的https改成刚刚自己的地址上面的红框处">第七步:将本地的仓库关联到GitHub,后面的https改成刚刚自己的地址,上面的红框处</h2>
<pre><code class="hljs dockerfile">git remote <span class="hljs-keyword">add<span class="bash"> origin 对应的github的路径
</span></span></code></pre>
<h2 id="第八步上传github之前pull一下">第八步:上传github之前pull一下</h2>
<p><span style="background-color: rgba(255, 255, 255, 1); color: rgba(51, 51, 51, 1)"><strong><span style="font-size: 15px"><code class="hljs nginx"><span class="hljs-attribute"> </span></code></span></strong><span style="font-size: 15px"><code class="hljs nginx"><span class="hljs-attribute"><span style="font-size: 12px">git pull origin master </span></span></code></span></span></p>
<h2 id="第九步上传代码到github远程仓库">第九步:上传代码到GitHub远程仓库</h2>
<pre><code class="hljs nginx"><span class="hljs-attribute">git push -u origin master
</span></code></pre>
<h2 id="中间可能会让你输入username和password你只要输入github的账号和密码就行了执行完后如果没有异常等待执行完就上传成功了">中间可能会让你输入Username和Password,你只要输入github的账号和密码就行了。执行完后,如果没有异常,等待执行完就上传成功了。</h2>
<h2 id="更新代码">更新代码</h2>
<h2 id="第一步查看当前的git仓库状态可以使用git-status">第一步:查看当前的git仓库状态,可以使用git status</h2>
<pre><code class="hljs lua">git <span class="hljs-built_in">status
</span></code></pre>
<h2 id="第二步更新全部">第二步:更新全部</h2>
<pre><code class="hljs dockerfile">git <span class="hljs-keyword">add<span class="bash"> *
</span></span></code></pre>
<h2 id="第三步接着输入git-commit--m-更新说明">第三步:接着输入git commit -m "更新说明"</h2>
<pre><code class="hljs nginx"><span class="hljs-attribute">git commit -m <span class="hljs-string">"更新说明"
</span></span></code></pre>
<h2 id="第四步先git-pull拉取当前分支最新代码">第四步:先git pull,拉取当前分支最新代码</h2>
<pre><code class="hljs nginx"><span class="hljs-attribute">git pull
</span></code></pre>
<h2 id="第五步push到远程master分支上">第五步:push到远程master分支上</h2>
<pre><code class="hljs nginx"><span class="hljs-attribute">git push origin master
</span></code></pre>
<h2 id="不出意外打开github已经同步了">不出意外,打开GitHub已经同步了</h2><br><br>
来源:https://www.cnblogs.com/yy0419/p/11151021.html
頁:
[1]