<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>项目上传 on iwmei的博客</title><link>https://iwmei.top/categories/%E9%A1%B9%E7%9B%AE%E4%B8%8A%E4%BC%A0/</link><description>Recent content in 项目上传 on iwmei的博客</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><copyright>iwmei</copyright><lastBuildDate>Mon, 16 Mar 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://iwmei.top/categories/%E9%A1%B9%E7%9B%AE%E4%B8%8A%E4%BC%A0/index.xml" rel="self" type="application/rss+xml"/><item><title>本地项目上传github的坑点与正确姿势</title><link>https://iwmei.top/p/all-git-push-the-right-way/</link><pubDate>Mon, 16 Mar 2026 00:00:00 +0000</pubDate><guid>https://iwmei.top/p/all-git-push-the-right-way/</guid><description>&lt;img src="https://iwmei.top/p/all-git-push-the-right-way/cover.png" alt="Featured image of post 本地项目上传github的坑点与正确姿势" />&lt;h1 id="本地项目上传github的坑点与正确姿势">本地项目上传github的坑点与正确姿势
&lt;/h1>&lt;ul>
&lt;li>首先，无论是什么IDE或者编辑器（VS、VScode、Pycharm、Idea、Clion等等），统统不要先在本地创建仓库。&lt;/li>
&lt;/ul>
&lt;h2 id="一些坑点">一些坑点
&lt;/h2>&lt;ol>
&lt;li>要先绑定github远程仓库，可能出现各种奇怪的问题；&lt;/li>
&lt;li>git创建的本地仓库，分支名字是 &lt;code>master&lt;/code> ，而github是 &lt;code>main&lt;/code> ，直接上传会导致不同分支，不好看；&lt;/li>
&lt;li>如果是使用IDE内的版本管理操作的，写完项目再创建仓库，添加文件是会出现困难，重新加 &lt;code>.gitignore&lt;/code> 太麻烦了，还可能有各种报错；&lt;/li>
&lt;li>仓库间文件不统一， 即使使用了 &lt;code>git pull&lt;/code> 也还是会报各种错误；&lt;/li>
&lt;li>可能因为各种权限问题导致被拒绝push。&lt;/li>
&lt;/ol>
&lt;h2 id="建议的正确姿势">建议的正确姿势
&lt;/h2>&lt;ol>
&lt;li>
&lt;p>进入github主页，点击 &lt;code>New&lt;/code> 创建同名的仓库；&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-link" data-lang="link">&lt;span class="line">&lt;span class="cl">&lt;span class="err">https://github.com/&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;ul>
&lt;li>点击左上角的绿色按钮，按照提示填即可。&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>创建完毕后，cd到项目存放地，使用 &lt;code>git clone&lt;/code> 命令把仓库克隆过来；&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-link" data-lang="link">&lt;span class="line">&lt;span class="cl">&lt;span class="err">git&lt;/span> &lt;span class="err">clone&lt;/span> &lt;span class="err">https://github.com/yourname/yourdepository&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;ul>
&lt;li>请在预存放项目的地方打开终端，执行上面的link，后面的仓库地址可以直接从仓库页面下的浏览器链接栏里面复制。&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>将你要上传的所有文件全部复制进clone下来的文件夹里面；&lt;/p>
&lt;ul>
&lt;li>注意，超过100MB的文件无法上传github；&lt;/li>
&lt;li>注意使用AI添加一个 &lt;code>.gitignore&lt;/code> 文件，把有的没的的路径都放进去。&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;span class="lnt">8
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-link" data-lang="link">&lt;span class="line">&lt;span class="cl">&lt;span class="err">__pycache__/&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="err">*.pyc&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="err">.env&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="err">venv/&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="err">.idea/&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="err">.vscode/&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="err">dist/&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="err">build/&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;li>
&lt;p>在终端中依次执行以下命令：&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-link" data-lang="link">&lt;span class="line">&lt;span class="cl">&lt;span class="err">git&lt;/span> &lt;span class="err">add&lt;/span> &lt;span class="err">.&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="err">git&lt;/span> &lt;span class="err">commit&lt;/span> &lt;span class="err">-m&lt;/span> &lt;span class="err">&amp;#34;init&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="err">git&lt;/span> &lt;span class="err">push&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;li>
&lt;p>后续的操作就转移到这个项目目录下进行即可，在IDE中图形化操作即可。&lt;/p>
&lt;/li>
&lt;/ol>
&lt;h2 id="总结">总结
&lt;/h2>&lt;p>请下次写项目前，先创建仓库别直接开写好吗 /smile&lt;/p></description></item></channel></rss>