1. Introduction
In the previous blog article "PythonAnywhere: Copy my projects to GitHub 2025.07.20", I researched what I should do. In this blog, I am going to put my projects onto GitHub actually.
2. Procedures
(1) Step 1: Create a Remote Repository on GitHub
- Go to GitHub and log in.
- Click on the “+” in the upper-right corner and select "New repository".
- Enter a repository name (e.g., my-documents-repo).
- Set the repository to Public.
- DO NOT initialize with a README or .gitignore (this avoids merge conflicts).
- Click Create repository.
- GitHub will show you commands for connecting your local repository—keep this tab open.
(2) Step 2: Initialize Your Local Repository
Go to your project site on PythonAnywhere
cd ~/django_projects/mysite
Initialize Git in the folder:
git init
This creates a hidden .git folder, marking it as a Git repository.
Change the branch name from `master` to `main`:
git branch -m main
Create README.md and put the comment in it:
echo "# django_projects-mysite" >> README.md
(3) Step 3: Connect Your Local Repository to GitHub
Add the GitHub repository as a remote
git remote add origin https://github.com/<your-username>/<repo-name>.git
Verify the remote repository was added:
git remote -v
You should see:
origin https://github.com/<your-username>/<repo-name>.git (fetch)
origin https://github.com/<your-username>/<repo-name>.git (push)
(4) Step 4: Stage, Commit, and Push Files
Let's upload only README.md:
git add README.md
git commit -m "first commit"
git push -u origin main
Enter your username.
Enter your token instead of your password. For your token, go to:
https://github.com/settings/tokens
and see Section 3 below.
(5) Step 4 again: Stage, Commit, and Push Files
This time upload everything:
git add .
git commit -m "initial all commit"
git push -u origin main
Again, enter your username, and then your token for your password.
3. Use of a token
I tried to do this:
git push -u origin main
But I got the following messages:
remote: Invalid username or token. Password authentication is not supported for Git operations.
fatal: Authentication failed for 'https://github.com/<your-username>/<repo-name>.git/'
Great — you're close! That error is very common, and it's happening because GitHub no longer supports password authentication for Git operations over HTTPS.
❌ The error:
This means you're trying to push using a password, but GitHub now requires one of these:
✅ Solution Options
🔐 Option 1: Use a Personal Access Token (PAT) (Recommended for HTTPS)
-
Go to GitHub:
https://github.com/settings/tokens -
Click "Generate new token (classic)"
-
Set:
-
Note: "Git Token"
-
Expiration: Choose something reasonable (e.g., 30 or 90 days)
-
Scopes: Check at least
repo
-
-
Click Generate token and copy it immediately (you won't see it again).
-
Now, when you run:
And it asks for a username, enter:
For password, paste the token you just copied.
[MY NOTE]
To navigate to the tokens page, go to
Settings > Developer Settings > Personal access tokens > Tokens (classic)
💾 Optional: Cache your credentials
Run this to save the token for future pushes:
Or, for permanent storage:
⚠️ With
store, your token is saved in plaintext in~/.git-credentials. Only use on trusted machines.
🔐 Option 2: Use SSH instead (Advanced but secure)
-
Set up an SSH key pair and add your public key to GitHub
-
Then change your remote URL to use SSH instead of HTTPS
Let me know if you'd prefer the SSH method — I can walk you through that too.
✅ TL;DR for You
Since you're using the HTTPS link:
-
Use a personal access token as your password
-
GitHub passwords no longer work for Git push/pull
Let me know if you want help generating the token or caching it securely!
4. LICENSE
(1)
I uploaded files onto my GitHub repo. I want to set a MIT license. How can I do it?
Great — adding a license is straightforward, and MIT License is one of the most permissive and commonly used licenses for open source.
✅ Option 1: Add the MIT License via GitHub Website
-
Go to your repository page on GitHub.
-
Click the "Add file" button (📄) → "Create new file"
-
In the filename, enter exactly:
-
On the right side of the editor, click "Choose a license template"
-
Select MIT License
-
GitHub will fill in the license text automatically.
-
Scroll down and click "Commit new file"
That’s it! You’ve licensed your project under MIT.
✅ Option 2: Add LICENSE file manually from your computer
-
Create a file named
LICENSEin your project directory -
Paste the MIT License content into it (see below)
-
Customize the year and your name
-
Stage, commit, and push:
📝 MIT License Template
👉 Full version: https://opensource.org/licenses/MIT
Let me know if you want me to generate the full text with your name and the current year — happy to do that!
(2)
Where is the add file button?
Great — here's how to find the "Add file" button on GitHub so you can add a LICENSE file:
✅ Steps to Find the "Add file" Button on GitHub
-
Go to your repository on GitHub
Example:https://github.com/yourusername/your-repo-name -
On the main repo page (where you see the list of files like
README.md, etc.), look for a green button near the top-right of the file list. -
You’ll see:
-
Click the ▾ next to "Add file"
You’ll see two options:-
Create new file
-
Upload files
-
-
Choose Create new file
-
In the "Name your file..." field, type exactly:
-
On the top right, you’ll see a link:
"Choose a license template" — click it. -
Select MIT License, edit your name/year, and click "Review and submit".
-
Scroll down and click the green "Commit new file" button.
Let me know your repo name if you want me to guide you directly to it — or if you’d prefer to add the license via terminal.
[MY NOTE]
Add file button is the "+" symbol button left to the green "Code" button.
5. git pull origin main
I created a license on GitHub remote repo. Should I do something with my local repo?
Great job adding the license on GitHub!
Yes — if you created the LICENSE file on GitHub, your local repo
is now behind the remote. You’ll want to pull the changes into your local project so both stay in sync.
✅ Step to update your local repo
In your local terminal (inside your project folder), run:
Replace
mainwith your branch name if you're using something else (likemaster).
🧪 What happens?
-
Git downloads the new
LICENSEfile from the GitHub remote repo -
It adds it to your local working directory
-
Now your local and remote repos match
✅ Then you’re done!
You don’t need to edit or re-add the license manually on your local repo — just pulling is enough.
Let me know if you get a merge conflict or need help resolving it.
[MY NOTE]
If you modify anything on the origin main (remote), then you will run:
git pull origin main
at your local repository.
If you modify anything on the local repository, then you will run:
git add .
git commit -m "commit message"
git push -u origin main
