How to connect a flutter project to GitHub

If you do not want to take risks for code loss and want to collaborate on your code with friends, colleagues, or anyone then Github is the best tool for it. So, here we will see the steps to connect a Flutter Project to GitHub.

You should have your flutter project ready which you want to connect with GitHub. I have my flutter project ready which is a counter application in Flutter.

Now login to your GitHub account and click on create a new repository.

How to connect a Flutter project to GitHub

Fill in all the details here –

Repository Name – This is a mandatory field. This will be the identifier for your repository on code. You can keep the project name as the repository name or whatever name you are comfortable with.

Description – This is an optional field. Here you can put a description of your project.

Public / Private – If you select Public, then the repository will be available to everyone on the internet. Anyone can download or view our code or contribute to your code. If you select private then this will be only visible to you or someone to whom you provide access to this repository.

Other Optional Fields – There are more optional fields you can select or unselect as per your choice. Usually, I leave them as it is.

Now, Click on Create Repository at the bottom.

Now your GitHub repository is created. Let’s come to our flutter project.

Run “git init” in the terminal in your project directory.

How to connect a Flutter project to GitHub

An empty Git Repository will be initialized in your project directory.

Run “git add .” This will add all the project files to the git repository.

Run git commit -m “first commit”. This is committing all your files to the git repository as your first commit.

How to connect a Flutter project to GitHub

Run “git branch -M master”. This will create a master branch as a default branch in your repository.

Run “git remote add origin <your-repository-url>”. This connects your git repository to the GitHub repository URL. Use your actual Github repository URL in the above command.

Run “git push -u origin master”. This will push your code GitHub repository.

How to connect a Flutter project to GitHub

That’s it. Happy Fluttering.

Read More Articles from me on my official website.

To stay tuned with me subscribe on youtube.

By Alok Singh Chauhan

I have been a full-stack software engineer for 5 years. Now, I teach programming and do some freelancing jobs. I write blogs and YouTube videos also.

Leave a Reply

Your email address will not be published. Required fields are marked *