DEV Community

Cover image for A Step-by-Step Guide to Committing and Pushing Changes in Git Using Visual Studio Code
Nikhil Soman Sahu
Nikhil Soman Sahu

Posted on

A Step-by-Step Guide to Committing and Pushing Changes in Git Using Visual Studio Code

  1. Create a New Repository on GitHub:

    • Go to GitHub and log in to your account.
    • Click the "+" sign in the upper-right corner and select "New repository".
    • Give your repository a name, optionally add a description, choose visibility settings, and select any other desired options.
    • Click "Create repository".
  2. Initialize Git in Your Project:

    • Open your BMI calculator project in your preferred code editor (e.g., Visual Studio Code).
    • Open the terminal within your code editor.
  3. Initialize Git:

    • Run the following commands in the terminal:
     git init
     git add .
     git commit -m "Initial commit"
    
  4. Connect Your Local Repository to GitHub:

    • Copy the URL of the repository you created on GitHub.
    • Run the following command in the terminal, replacing <repository-url> with the actual URL:
     git remote add origin <repository-url>
     git branch -M main
     git push -u origin main
    
  5. Push Your Code to GitHub:

    • Run the following command to push your code to GitHub:
     git push origin main
    
  6. Your Code is on GitHub:

    • Refresh your GitHub repository page, and you should see your code uploaded.
  7. Updating Your Repository:

    • Whenever you make changes to your code, you can use the following commands to update your GitHub repository:
     git add .
     git commit -m "Update"
     git push origin main
    

Remember to keep your sensitive data (like API keys) out of your public repositories. You can use environment variables or other methods to manage such information securely.

Please note that this is a general guide. Make sure to refer to official documentation or tutorials for more detailed instructions tailored to your specific development environment and tools.

Top comments (0)