To work on your GitHub repo from your local machine using VS Code, follow out these steps here :-
- Open GitHub and navigate to yours repository.
- Click the "Code" button and copy the repository HTTPS URL.
- Open VS Code and open the terminal (
Ctrl + ~orView > Terminal). - Run the following command to clone the repo:
Example:
git clone <repository_url>
git clone https://github.com/your-username/your-repo.git
- Navigate into the project folder:
cd your-repo - Open the project in VS Code:
code .
- Modify or add files in the project using VS Code.
- Check the status of your repository:
git status
- Stage the changes:
git add . - Commit the changes with a message:
git commit -m "Your commit message"
- Pull the latest changes (to avoid merge conflicts):
git pull origin main
- Push your local changes to GitHub:
git push origin main
- Next time, you can directly pull the latest changes before working:
git pull origin main
- After making changes, repeat Step 2 & Step 3 to commit and push them.
Let me know if you face any issues.