How to start a new Github repo from an existing project

Assume that you have a project and you want to track it with Github.

Navigate to the project folder, and initialize git by running

git init .

Create a .gitignore file to specify files that you want to ignore when pushing all your files to remote repo (i.e., specify files you don’t want to track)

Then add all relevant files of the project and do commit

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

Say you’ve already set up a brand new repo on Github dedicated to the project.

Now let’s connect our local repo to that remote Github repo:

git remote add origin https://username@github.com/username/reponame
git pull origin main --allow-unrelated-histories

Now push your project to the remote repository by running the following command

git push origin main

That’s it.


More Articles

How to check for listening ports in Linux

Here is one of the most popular commands for troubleshooting network or specific application problem...

codezilla

codezilla

How to get octal file permissions from command line?

Sometimes we want to know the octal number representing the permission of a file like 755, 777, 664 ...

codezilla

codezilla