There are lots of ways you can share and collaborate using your existing work on GitHub.
Note: You can also use GitHub Desktop to add your project if you want to work with a point-and-click user interface. However, it is not suggested storing business-critical or sensitive information like PIN, Passwords, API Keys, etc. in a remote repository.
Do not use README or license files to initialize the new repository. These files can be added later after loading the project to GitHub.
- Open Git Bash.
- Make your local project as your current working directory.
- Initialize your local directory using the following command.
$ git init
- Add the files in your local repository using the following command.
$ git add
The command stages the added file for commit. You can use the ‘git reset HEAD yourfile’ to unstage a file.
- Commit the files from local repository using the following command.
$ git commit –m ‘First commit’
This command commits the changes and prepares them to be pushed on the remote repository. You can use the ‘git reset –soft HEAD~1’ command to modify the file.
- Copy the remote repository URL from your GitHub page.
- Go to the command prompt and add the remote repository URL where your local repository will be pushed. This can be done using the following command.
$ git remote add origin remote repository URL
This sets the new remote
$ git remote –v
This verifies the URL
- Push the changes to GitHub.
$ git push origin master
This pushes the changes in local repository to GitHub.
You may also like: How to Open a GitHub Project Using Visual Studio?