Adding an existing project to GitHub using the command line

Github

GitHub is a Git repository hosting service, web-based. It offers all of the distributed version control and SCM (source code management) functionality of Git as well as adding its own features. It provides several collaboration and access control features such as bug tracking, feature requests, task management. GitHub offers both plans for free repositories on the same account  which are commonly used to host open-source software projects and private repositories.

There are two ways to add project in Github as following:

  1. Directly  from Android Studio.
  2. Using the Command line (Terminal).

Today, We will learn about add project to Github using the command line (Terminal).

Steps for adding an existing project to Github using the command line:

  1. First of all Login og Sign Up on Github.
  2. After that you will see the plus sign on the right corner of your screen. From that select New Repository.
    screen-1
  3. Then you will see the new window , Where you can enter your repository name like TestRepository.
    screen-2
  4. After that your repository will be created. Now you can see Quick setup Window in front of you.  Here you can see your HTTPS and SSH url.
    screen-3
  5. Now open you Terminal.
  6. Then after you have to change your current working directory to your local project directory.  For that you have to fire “cd” command with your project directory path.
    Shortcut:
    • Type “cd” command and directly drag and drop your project directory to the terminal. You will see the full path of your local project directory.
    • Type “cd” command and just copy your project directory and paste after “cd” command. You will get full path of your local project directory.
      Then you will redirect to your local project directory.
      screen-4
  7. Now initialize your local project directory as a Git repository using “init” command.
    screen-5
  8. Now add all your files to the new local project directory.
    screen-6
  9. After adding all files, You have to commit that staged files by particular tag just for your remind like “test commit”.
    screen-7
  10. From the Quick Setup Window  copy Repository URL.
    screen-8
  11. In terminal add your repository URL for the remote repository, Where your local project repository will we pushed. This command will sets new remote for your repository.
    screen-9
  12. Now push all changes of your local project repository to the Github. It will push all code to the Github.
    screen-10

Finally, your local repository placed in Github. Now you can see your project in your Github repository.

mm

Payal Senjaliya Android Developer

I am an Android Developer at Yudiz Solutions Pvt. Ltd. - a leading mobile app development company. I like to work with real-time data communication with hardware connectivity, to maximize development efficiency and produce innovative applications.

Comments are closed.

Top