Skip to content

Latest commit

 

History

History
121 lines (91 loc) · 2.8 KB

Git.md

File metadata and controls

121 lines (91 loc) · 2.8 KB

Creating a New Git Repository and Adding Files

1. Initialize a New Git Repository

To create a new Git repository, navigate to your project directory and run:

git init

2. Add Files to the Repository

After initializing the repository, add your project files:

git add .

3. Commit the Files

Once the files are added, commit them with a meaningful message:

git commit -m "Initial commit"

4. Add a Remote Repository

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.

5. Push to GitHub

Push the committed files to GitHub:

git push -u origin main

Removing Stored Git Credentials

Clear Saved Credentials in Git

To remove stored Git credentials, use the following command:

git credential reject https://github.com

Remove Stored Credentials on Windows

If you are using Windows, you may also need to remove the stored credentials from Windows Credential Manager:

  1. Open Control Panel.
  2. Navigate to Credential Manager.
  3. Select Windows Credentials.
  4. Find the entry for GitHub.
  5. Click Remove to delete the stored credentials.

Remove Stored Credentials on macOS/Linux

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.

Adding multiple users in the same machine:

https://www.youtube.com/watch?v=6lA0oPoFCAE&ab_channel=JcMiron

Deploying Vite + React App on GitHub Pages

Follow these steps to deploy your Vite + React app to GitHub Pages.

Step 1: Update vite.config.js

Add the following line:

export default defineConfig({
  base: "/repo-name/",
  plugins: [react()],
});

Step 2: Update package.json

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"
  }
}

Step 3: Install gh-pages

Run the following command in your terminal:

npm install --save gh-pages

Step 4: Deploy the App

Run:

npm run deploy

Once the deployment is complete, you will see a message indicating that the app has been published.

Step 5: Access Your App

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!