Use Github for your Existing Flutter Project

Rex Cole
2 min readAug 5, 2024

--

Todo:

  • Create Github Repository
  • Initialize Local Project
  • Add files to the Repository
  • Add the remote Repository
  • Push the Project to the Github

Create a GitHub Repository

  1. Sign in to GitHub: Go to GitHub and sign in or create an account if you don’t have one.
  2. 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

  1. Open a terminal or command prompt.
  2. 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

  1. 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 and my-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:

--

--

No responses yet