(Example: Pushing a WordPress Site from /var/www/sample.com/public_html)
Gitea is a lightweight, self-hosted Git server that makes it easy to manage your code privately. In this guide, we’ll show you how to Push a Fresh Git Repository to Your Gitea Server and upload your website files (e.g., a WordPress project) using the command line.
Let’s assume your website files are located in:
/var/www/sample.com/public_html
Step 1: Navigate to Your Project Directory
cd /var/www/sample.com/public_html
This command simply takes you into the folder where your project (WordPress site) is located.
Step 2: Initialize a New Git Repository
git init
This initializes a new Git repository in your current directory. Git will now start tracking changes to the files in this directory.
Step 3: Create a README File (Optional but Recommended)
touch README.md
A README.md file provides basic information about your project — like what it does, how to install it, or how to use it. It’s also the first thing most users see when they visit your repo on Gitea.
Step 4: (Optional) Create a .gitignore File
nano .gitignore
Add common WordPress exclusions:
wp-config.php
wp-content/uploads/
*.log
*.zip
.gitignore tells Git which files/folders it should not track. This is helpful for excluding sensitive or bulky files like: Configuration files (e.g., wp-config.php), uploaded media, log files and temporary data
Step 5: Create and Switch to the Main Branch
git checkout -b main
By default, Git creates a branch called master. Many teams now use main as the primary branch name, and this command switches to a new branch named main.
Step 6: Stage and Commit Files
git add .
git commit -m "Initial commit - WordPress site"
git add . add all files for commit.
git commit -m creates a snapshot of the current state of your project with a message describing the changes.
Step 7: Add Remote Repository (Gitea)
First, create a repository on your Gitea server (via the web interface). Then connect your local repo to the remote one:
git remote add origin http://65.xx.xxx:3000/gituser/repo_name.git
This tells Git where to push your code — in this case, to your Gitea server.
Step 8: Push Code to Gitea
git push -u origin main
You may be prompted for Gitea credentials during the push.
For Existing Repositories
If you already have a Git repo (initialized and committed), just add the remote and push:
git remote add origin http://65.xx.xxx.xxx:3000/gituser/repo_name.git
git push -u origin main
Bonus Tip: Use SSH Instead of HTTP (Optional)
Set up SSH in Gitea for secure push/pull without entering your password:
git remote set-url origin git@your-gitea-server:gituser/auto_deploy-test2.git
Conclusion
If you’re facing challenges or need expert help to Push a Fresh Git Repository to Your Gitea Server, our team at Skynats is here to assist you. With our professional server management services, we ensure your Git server is configured securely and performs optimally. Whether it’s initial setup, troubleshooting, or automation integration, we’ve got you covered.
Contact us today to streamline your Git workflow with confidence!