Table of Contents
- 2. Check whether Git is already initialized
- 3. Review .gitignore
- 4. Use main as the branch name
- 5. Stage the project files
- 6. Review what will be committed
- 7. Create the initial commit
- 8. Create an empty repository in Forgejo
- 9. Connect the local project to Forgejo
- 10. Push the project to Forgejo
- 11. Verify the repository
- Normal Workflow After Import
- Important Notes
# Import an Existing Project into Forgejo
This guide describes how to take an existing local project and turn it into a Git repository backed by Forgejo.
## 1. Open the project folder
In PowerShell:
```powershell
cd C:\Dev\project-name
Replace project-name with the actual project folder.
Example:
cd C:\Dev\family-dashboard
2. Check whether Git is already initialized
Run:
git status
If Git is already initialized, you will see the current branch and repository status.
If you see:
fatal: not a git repository
initialize the folder:
git init
3. Review .gitignore
Before adding files, make sure the project has an appropriate .gitignore.
The .gitignore file is project-specific. It should exclude things that do not belong in source control, such as:
.env
.env.*
node_modules/
.venv/
__pycache__/
dist/
build/
*.log
Depending on the project, you may also want to exclude:
data/
artifacts/
*.db
*.sqlite
*.bak
Do not blindly copy the same .gitignore to every project. Review what the specific application generates and what data it stores locally.
4. Use main as the branch name
Run:
git branch -M main
5. Stage the project files
Run:
git add .
Git may display warnings about LF and CRLF line endings on Windows. These are normally informational and do not prevent the files from being staged.
6. Review what will be committed
Run:
git status
Carefully inspect the files under:
Changes to be committed:
Make sure you do not see anything that should remain private or local, such as:
.env- passwords
- API keys
- tokens
- private certificates
- runtime databases
- large generated files
- dependency folders such as
node_modules - local caches
- temporary files
If something appears that should not be committed, update .gitignore before continuing.
7. Create the initial commit
Run:
git commit -m "Initial import"
If Git asks you to configure your identity, set it once globally:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
Then retry:
git commit -m "Initial import"
The Git identity is the author information stored with commits. It is separate from Forgejo authentication.
8. Create an empty repository in Forgejo
In Forgejo:
- Create a new repository.
- Give it the same or similar name as the local project.
- Do not initialize it with:
- a README
- a
.gitignore - a license
The repository should be empty because the local project already contains the source files.
9. Connect the local project to Forgejo
Forgejo will provide a repository URL.
Example using the local Forgejo server:
git remote add origin http://192.168.29.126:3004/USERNAME/project-name.git
Replace USERNAME and project-name with the actual Forgejo username and repository name.
Example:
git remote add origin http://192.168.29.126:3004/rolfkrauss/family-dashboard.git
If an origin remote already exists, check it first:
git remote -v
To replace the existing origin URL:
git remote set-url origin http://192.168.29.126:3004/USERNAME/project-name.git
10. Push the project to Forgejo
Run:
git push -u origin main
Forgejo may ask you to authenticate or authorize access.
The -u option connects the local main branch to origin/main, so future pushes and pulls can use shorter commands.
11. Verify the repository
Check locally:
git status
git remote -v
A healthy result should look similar to:
On branch main
Your branch is up to date with 'origin/main'.
nothing to commit, working tree clean
Then open the repository in Forgejo and confirm that you can see:
- project files
- the
mainbranch - commit history
- the initial commit
Normal Workflow After Import
The local project folder remains the normal working copy.
Forgejo acts as the central remote repository.
Before starting work:
git pull
After making changes:
git status
git add .
git commit -m "Describe the change"
git push
A typical workflow is therefore:
Local project folder
|
| Git tracks changes
v
Local Git repository
|
| push / pull
v
Forgejo repository
Important Notes
Do not delete the local project folder after pushing
Forgejo is the central repository, but the local folder is still the working copy used by Codex, Claude, editors, build tools, tests, and other development tools.
If the local folder is ever deleted, it can be recreated by cloning the repository again.
Example:
git clone http://192.168.29.126:3004/USERNAME/project-name.git
.gitignore is project-specific
A Node project, Python project, Docker project, Dataverse solution, and .NET project may all require different exclusions.
Always review the staged files with:
git status
before the first commit.
Git and Forgejo are separate
Git is the local version-control system.
Forgejo is the remote Git server.
Git stores the project history locally inside the hidden .git folder.
Forgejo stores a remote copy of that Git history and allows repositories to be accessed from multiple machines.