Tuesday, April 28, 2020

How to add existing files into GitHub using command line - Add project to GitHub

Let us say you have a source files and you would like to check-in the source files into GitHub.

How will you do add project/source files from your machine into GitHub?

Pre-requistes:

1. Make sure git is installed on your source machine.
2. Make sure you add SSH public keys to GitHub by executing ssh-keygen command.

1. Create a new repo in GitHub. Do NOT create README file yet.
 
Once you create the repository. it should show something like below:

2. Open git bash or command line terminal
3. navigate to your directory where you have source files.
4. run the below command to initialize the directory as local repository.
       git init
5. Execute git add .
6. git commit -m "my project setup in GitHub"
7. git remote add origin remote repository URL
(take the remote repo url from above image, marked in red color )
8. git push -u origin master

Now login to GitHub and make sure code is available under source tab for the repo. 

No comments:

Post a Comment

How to Configure GitHub Advanced Security for Azure DevOps | How to Perform Security scan for Azure Repos using GitHub Advanced Security

GitHub Advanced Security for Azure DevOps brings the  secret scanning, dependency scanning  and  CodeQL code scanning  solutions already ava...