1. Initialize Git (if not already initialized)
If you haven’t already initialized Git in your local project folder, do so with:
git init
2. Add a Remote Repository
If you haven’t linked your local repository to a remote repository yet, add a remote:
git remote add origin <REMOTE_URL>
Replace with the URL of your remote repository (e.g., a GitHub repository link).
To check if the remote is added, use:
git remote -v
3. Add and Commit Your Changes
Stage all changes in your local repository:
git add .
Commit the staged changes with a message:
git commit -m "Commit Message"
4. Push to the Remote Repository
Now push your code to the remote repository's main branch (replace main with your branch name if it's different):
git push -u origin main
The -u option sets origin/main as the default upstream branch. This way, future git push commands can be done without specifying origin and main.
5. Verify Your Push
After pushing, you can check your repository on GitHub or your Git hosting provider to ensure your code was uploaded successfully.
Happy Coding!