Uploading VS Code Project to GitHub
Introduction
The following provides information on upload a VS Code project to GitHub.
Instructions
- Make sure you have git installed on your computer.
- Create a GitHub account (in case you don't have one).
- Create a GitHub repository/folder
- Head to the GitHub home (dashboard).
- Look for the + on the menu and select "New Repository"
or search for "Create a new repository" to locate the
button that will allow you to create it.
- Enter a name for your repository.
- Select private or public (use private if it is a class project implementation).
- Click on the "Create repository" button to create the repository.
- After clicking on the button, locate the link that is associated with the
repository on the page that appears. For example, a link to a repository
DeploymentExample will be similar to:
https://github.com/NelsonPaduaPerez/DeploymentExample.git
- To initially upload a VS Code folder to the repository
- Open the project folder in VS Code.
- Open a VS Code terminal and make sure you are in the project folder.
- Execute the following commands
- git init
- git add . (notice there is a period)
or add any files by using git add followed by the file/directory name
(e.g., git add sample.js)
- git commit -m "first commit (or any message you want)"
- Verify the main development branch name by executing
git branch. If the branch is named master,
you will see "* master". For GitHub, change it to
main by executing git branch -m master main
- git remote add origin PUT_HERE_URL_ABOVE_REPRESENTING_GITHUB_REPOSITORY
- git push -u origin main
This will pop up a window for you to log on to GitHub.
You can verify you have uploaded your code by visiting the
GitHub main page, selecting "Repositories" and the name of
your repository.
-
Notice: A .git folder is created in the VS project folder; you may want
to remove it to start again with the setup process. It is hidden, so
in Windows you may need to change your settings see it
(e.g., View->Show->Hidden Items).
- Execute the following commands to upload to GitHub changes you make to your code
- git add . (notice there is a period)
or add any files you edited by using git add followed by the file/directory name.
- git commit -m "Your message describing the changes goes here"
- git push
- At some point, you might need to execute the following command
git config --global user.email "YOUR_MAIL_ADDRESS"