Create a GitHub Repository
- Sign in to GitHub: Go to GitHub and sign in or create an account if you don’t have one.
- Create a new repository:
- Click on the + icon in the top right corner and select “New repository”.
- Name your repository (e.g.,
my-flutter-project
). - Add a description (optional).
- Choose the repository to be Public or Private.
- Do not initialize the repository with a README,
.gitignore
, or license (you'll add these from your local project). - Click on “Create repository”.
2. Initialize Git in Your Local Project
- Open a terminal or command prompt.
- Navigate to your Flutter project directory:
cd path/to/your/flutter-project
3. Initialize a new Git repository:
git init
3. Add Files to the Repository
- Add all your project files to the Git staging area:
git add .
2. Commit the files:
git commit -m "Initial commit"
3. Change your branch to ‘main’:
git branch -M main
This is neccessary, because Github Changes its main branch from master to main
4. Add the Remote Repository
Add the GitHub repository as a remote:
git remote add origin https://github.com/your-username/my-flutter-project.git
Replace
your-username
andmy-flutter-project
with your GitHub username and repository name.
5. Push Your Project to GitHub
Push your local repository to GitHub:
git push -u origin main
6. Verify Your Project on GitHub
- Go to your GitHub repository URL in your browser.
- You should see your Flutter project files listed in the repository.
Now your local Flutter project is uploaded to GitHub, and you can continue to manage it using Git commands.
EXTRA:
How to delete my local git:
How to change branch: