Actual GitHub Setup
Setting up GitHub on your system involves a few steps: installing Git, configuring your Git environment, and connecting your local repository
to a GitHub repository. Here’s a step-by-step guide:
Step 1: Install Git
On Ubuntu/Debian-based systems:
1 sudo apt update
2 sudo apt install git
On CentOS/RHEL-based systems:
1 sudo yum install git
On Fedora:
1 sudo dnf install git
On macOS:
You can use Homebrew:
1 brew install git
On Windows:
Download and install Git from the official website.
Step 2: Configure Git
Set up your Git username and email address. This information will be associated with your commits.
1 git config --global user.name "Your Name"
2 git config --global user.email "your_email@example.com"
You can verify your settings with:
1 git config --global --list
Step 3: Generate SSH Key (Optional but Recommended)
To securely connect to GitHub, you can generate an SSH key. This step is optional but recommended for secure communication with
GitHub.
1. Generate a new SSH key:
1 ssh-keygen -t ed25519 -C "your_email@example.com"
If you are using an older system that doesn’t support the Ed25519 algorithm, use:
1 ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
2. When prompted to "Enter a file in which to save the key," press Enter to accept the default file location.
3. Add your SSH key to the ssh-agent:
1 eval "$(ssh-agent -s)"
2 ssh-add ~/.ssh/id_ed25519
If you used RSA:
1 ssh-add ~/.ssh/id_rsa
4. Add the SSH key to your GitHub account:
Copy the SSH key to your clipboard:
1 cat ~/.ssh/id_ed25519.pub
Or for RSA:
1 cat ~/.ssh/id_rsa.pub
Go to GitHub, navigate to Settings > SSH and GPG keys > New SSH key, and paste the key.
Step 4: Clone a Repository
1. Go to the repository you want to clone on GitHub.
2. Click on the Code button and copy the repository URL.
3. Clone the repository:
1 git clone git@github.com:username/repository.git
Or if you're using HTTPS:
1 git clone <https://github.com/username/repository.git>
Step 5: Make Changes and Push
1. Navigate to your repository:
1 cd repository
2. Make your changes and stage them:
1 git add .
3. Commit your changes:
1 git commit -m "Your commit message"
4. Push your changes to GitHub:
1 git push origin main
If your default branch is master , replace main with master .
Step 6: Pull Changes (if necessary)
To update your local repository with changes from the remote repository:
1 git pull origin main
Replace main with the appropriate branch name.
Optional: Setting Up a Personal Access Token (PAT) for HTTPS (if not using SSH)
1. Go to GitHub and navigate to Settings > Developer settings > Personal access tokens > Tokens (classic) > Generate new token.
2. Select the scopes/permissions you need and generate the token.
3. Use this token as your password when pushing/pulling over HTTPS.
1 git clone <https://github.com/username/repository.git>
When prompted for a password, use the PAT instead of your GitHub password.
By following these steps, you should have GitHub set up and ready to use on your system.