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 https://username@github.com/username/reponame
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 a skilled programmer specializing in Vue.js/Nuxt.js for front-end development and PHP Laravel for back-end solutions. I have a strong focus on API design and development, complemented by experience in web server setup and maintenance. My versatile expertise ensures seamless creation and maintenance of web applications, covering everything from intuitive user interfaces to robust server-side functionality. Passionate about coding and driven by a lifelong learning mindset, I invite you to explore more at danyal.dk.