To create a new Git repository, navigate to your project directory and run:
git init
After initializing the repository, add your project files:
git add .
Once the files are added, commit them with a meaningful message:
git commit -m "Initial commit"
To link your local repository to a remote GitHub repository, use:
git remote add origin https://github.com/YOUR_USERNAME/YOUR_REPOSITORY.git
Replace YOUR_USERNAME
and YOUR_REPOSITORY
with your GitHub details.
Push the committed files to GitHub:
git push -u origin main
To remove stored Git credentials, use the following command:
git credential reject https://github.com
If you are using Windows, you may also need to remove the stored credentials from Windows Credential Manager:
- Open Control Panel.
- Navigate to Credential Manager.
- Select Windows Credentials.
- Find the entry for GitHub.
- Click Remove to delete the stored credentials.
For macOS and Linux users, use the following command:
git credential reject https://github.com
If you are using a credential helper (like Keychain on macOS), you may need to clear stored credentials:
security delete-generic-password -s github.com
After clearing credentials, the next time you push or pull from GitHub, you will be prompted to enter your credentials again.
https://www.youtube.com/watch?v=6lA0oPoFCAE&ab_channel=JcMiron
Follow these steps to deploy your Vite + React app to GitHub Pages.
Add the following line:
export default defineConfig({
base: "/repo-name/",
plugins: [react()],
});
Modify the package.json
file:
{
"name": "your-app-name",
"homepage": "https://github_username.github.io/repo-name/",
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d dist"
}
}
Run the following command in your terminal:
npm install --save gh-pages
Run:
npm run deploy
Once the deployment is complete, you will see a message indicating that the app has been published.
Visit:
https://github_username.github.io/repo-name/
At first, you may see a 404 error. Reload the page 2-3 times, and your app should appear successfully hosted on GitHub Pages!