Adding an existing project to GitHub using the command line
In this post we will give you information about Adding an existing project to GitHub using the command line. Hear we will give you detail about Adding an existing project to GitHub using the command lineAnd how to use it also give you demo for it if it is necessary.
Adding an existing project to GitHub using the command line
In this post, i will tell you how to push your existing projects on GitHub by command prompt.
Before going with this post i let you know some important tips :
Never push, commit or add sensitive information to a remote repository.
Sensitive information can be :
- Passwords
- API keys
- Credit card numbers
- PIN numbers
- SSH keys
- AWS access keys
I suggest you to remove sensitive data before putting any existing project on github.
Step 1: Create a new repository
In this step, you will have to first create a new repository so that you can push your project in particular repository from terminal.
Step 2: Initialize Git
To create a new Git repository, first open terminal and change directory to your local project and fire command git init command from terminal, this will create empty Git repository.
$ git init
Step 3: Add files to git repository
You have empty repository but nothing in it so start to add files with add command.
You can add specific file by running following command :
$ git add <filename>
You can add all file by running following command :
$ git add .
Step 4: Write a Git commit message
This is the best way to communicate context about a change to fellow developers that means if you make changes in any files and update this files on github with updated commit message then fellow developers can easily understand that changes are made in this files.
$ git commit -m "Add new files"
Step 5: Adding a remote
You will have to first copy the remote repository URL :
You will have to run git remote add to add new remote from your terminal.
This command will ask two arguments :
- A remote name, for example, origin
- A remote URL, for example
$ git remote add origin remote-repository-url
# Sets a new remote
$ git remote -v
# verify new remote
If you are getting error : remote origin already exists. then you can fix it by :
- Change name for the new remote
- Rename the existing remote
- Delete the existing remote
Step 6: Push the changes
In this step simply push to the master branch by running following command :
$ git push origin master
Version control system is very useful for software development to handle everything from small to very large projects with efficiency.
Hope this code and post will helped you for implement Adding an existing project to GitHub using the command line. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs