Start a new Github repo from an existing project

Suppose you have a project and wish to start tracking it with Github, Bitbucket or AWS CodeCommit.

First you need to navigate to the project folder locally & run the following command to initialize the git.

git init .

One of the best practices when using git is to maintain project .gitignore file, in order to ignore files & folders when pushing files to the remote repo.

Then add all files & folders from current project and do commit by running the following command.

git add .
git commit -m"A message for the commit"

Assuming that you have already repo in for example Github, let connect the local repo to the remote Github repo by running the folowing commands.

git remote add origin
git pull origin master --allow-unrelated-histories

Now it’s time to push project source to the remote repo by running the following command.

git push origin master
Flow Example
Flow Example

That is all you need to do, quite simple isn’t it 🙂

Author: Danyal
I'm skilled programmer with expertise in Vue.js/Nux.js for front-end development and PHP Laravel for back-end development. I excel in building APIs and services, and also have experience in web server setup & maintenance. My versatile skill set allows you to develop and maintain web applications effectively, from the user interface to the server-side functionality. I love coding with never ending learning attitude, thanks for visiting