Setup Git Referance
Git Setup Guide test
Setting Up SSH for Git
To securely connect to GitHub using SSH, follow these steps to generate an SSH key and configure your GitHub account.
Step 1: Generate an SSH Key
- Open Terminal or Command Prompt:
- On Windows, you can use PowerShell or Command Prompt.
- Run the SSH Key Generation Command:
- Use the following command to create a new SSH key:
1
ssh-keygen -t ed25519 -C "your_email@example.com"
Replace “your_email@example.com” with your actual email address.
Follow the Prompts:
- You will be asked where to save the key. Press Enter to accept the default location.
- Optionally, set a passphrase for added security.
Step 2: Add the SSH Key to the SSH Agent
- Start the SSH Agent:
- Run the following command to ensure the SSH agent is running:
1
eval "$(ssh-agent -s)"
- Add Your SSH Key:
- Use the command below to add your SSH key to the agent:
1
ssh-add ~/.ssh/id_ed25519
- Adjust the path if you saved your key in a different location.
Step 3: Add the SSH Key to Your GitHub Account
- Copy the Public Key:
- Use the following command to copy your public key to the clipboard:
1
cat ~/.ssh/id_ed25519.pub
Alternatively, open the file in a text editor and copy its contents.
- Log into GitHub:
- Go to your GitHub account settings.
- Add a New SSH Key:
- Navigate to SSH and GPG keys.
- Click on New SSH key, paste your public key, and save it.
Step 4: Test Your SSH Connection
- Run the following command to test the connection:
1
ssh -T git@github.com
- You should see a message confirming a successful connection.
By following these steps, you will have set up SSH for Git, allowing secure communication with GitHub.
Setting Up Your Git Username and Email
To properly configure your Git environment, you need to set your username and email address. This information is crucial as it is associated with every commit you make.
Global Configuration
To set your username and email globally (for all repositories on your system), use the following commands in your terminal:
- Set your username:
1
git config --global user.name "Your Name"
- Set your email:
1
git config --global user.email "you@example.com"
Local Configuration
If you want to set a different username or email for a specific repository, navigate to that repository’s directory and run:
- Set your username:
1
git config user.name "Your Name"
- Set your email:
1
git config user.email "you@example.com"
Verifying Your Configuration
To check if your username and email have been set correctly, use the following command:
1
git config --list
This will display all your Git configuration settings, including the username and email.
Important Notes
- The global settings apply to all repositories unless overridden by local settings.
- Changes made will only affect future commits; past commits will retain the original information.