Uploading Files to GitHub Using Git

📢 This article was translated by Gemini-3-flash

Written by Hiyoung

Original Article: https://blog.hiyoung.icu/2022/08/03/0b5e2db181ab/

I’ve been using GitHub a lot lately to store code from my learning process. I realized you can’t upload folders directly through the web UI, so I looked into using Git for uploads. Here’s a quick post to document the process.

GitHub Operations

1. Copy Repository URL

Uploading files to GitHub via Git_1

Local Operations

1. Create a New Empty Folder Locally

Uploading files to GitHub via Git_2

I’ve already finished the clone here.

2. Open Git Bash in the Folder

Uploading files to GitHub via Git_3

3. Clone Remote Repository

1
2
<pre class="language-bash" data-info="bash" data-role="codeBlock"><span class="token function">git</span> clone + your_repo_address
<span class="token function">git</span> clone https://github.com/hiyoung3937/study_code.git  // Example

4. Drag and Drop Files to Upload

5. Upload

1
2
3
4
5
<pre class="language-bash" data-info="bash" data-role="codeBlock"><span class="token builtin class-name">cd</span>  study_code.git   // Enter your repository name
<span class="token function">git</span> init
<span class="token function">git</span> <span class="token function">add</span> <span class="token builtin class-name">.</span>
<span class="token function">git</span> commit -m "your commit message"
<span class="token function">git</span> push

Command Descriptions

clone + repository addressClones your repository to the local machine
cd + your remote repository nameEnters the remote repository folder (input based on your repo name)
git initInitializes Git
git add .Adds workspace files to the staging area ("." adds all files in the current directory; can also specify a folder name)
git commit -m “your commit message”Adds files from the staging area to the local repository
git pushPushes to the remote repository (may require credentials)
This post is licensed under CC BY-NC-SA 4.0 by the author.