Creating New Repo & Adding Project To GitHub Using Command Line/ Terminal

Creating New Repo & Adding Project To GitHub Using Command Line/ Terminal

·

3 min read

Hello everyone👋!!

In this article, I have mentioned how to create a repository on Github and write some basic git commands in order to add your local project to Github using the command line/ terminal or git bash.

This is the article for beginners🤩 who don't know what is Git and Github but want to learn the basics of creating a repo & adding the project to Github.

Do give it a read:)

📋Follow the steps along with me:

Reminder: If you haven't made a Github account, then make sure you have it.

Sign up On Github

⭐Creating a new repository:

  1. Open Github on desktop and on the right side you will find a + icon.
  2. Click that icon and you will get the first drop-down menu as "New Repository", click on that.
  3. By doing this you will be rendered to a new window asking your Repository name, description(optional), fill in all the details that are required.
  4. Further you are asked whether to keep the repo public or private, you can choose whatever you wish to.
  5. At last you are asked to add a readme file, .gitignore file, and choose a license. That's again optional.

I would suggest always add a readme file as it makes out your repo look more good & informative. Also, it is easy for others to understand what your project is about by reading a readme file.

⭐Adding an existing project to Github using terminal:

  1. Open a terminal in the current working directory (which has the project you want to add).
  2. Initialise git repository by typing the following command:

    git init

  3. Add all the files and folders from your local server project to Github by writing a command:

    git add .

  4. Commit the files that you’ve staged in your local repository with a short & informational message.

    git commit -m "Type your message...."

  5. Now, go to the GitHub repository that you have created above and copy the HTTPS URL.
  6. In the terminal copy the following command:

    git remote add origin "remote repository URL"

    Here instead of remote repository URL, paste the URL of a new repo that you have just copied. Example:

    git remote add origin https://github.com/Isha2103/abc.git

  7. Next write the given command, this is used to connect your local repository to the remote server.

    git remote -v

  8. Now Push the changes in your local repository to GitHub.

    git push origin master

    After this command it asks you for Github username and password, type it and your changes are pushed to Github.

Refresh the Github window and you will see all the files and folders are added to the repo. And with this, you have added your project from the local server to Github.

Hope you find this article helpful🤩!!

Please leave your thoughts below and share this article with your friends.😇

Connect with me: