Keegan Turner
  • πŸ‘‹Hello World.
  • πŸ“šHow-To Guides
    • Integrating Git on your local host
    • βš–οΈLoad Balancing with HAProxy
    • πŸ‘¨β€πŸ’»Code Server - Self Hosted VSCode alternative
    • πŸ•ΈοΈWordPress + LAMP - Self Hosted CMS
    • ☁️Nextcloud - Self Hosted file sync & sharing solution
    • ⏳Grafana Cloud - Cloud Hosted Monitoring
    • βŒ›Prometheus + Grafana - Self Hosted monitoring stack solution
    • πŸ›³οΈPortainer + Docker - Self Hosted container management UI
    • 🐬MariaDB - Self Hosted database server
    • πŸ€–Let's Encrypt + Certbot - Secure your web services with SSL certificates
    • ◀️Nginx Proxy Manager - Self Hosted domain controller with LE SSL certificates
    • πŸ–₯️LXD - Linux OS containers
    • 🐧Linux basics: commands
    • 🐧Linux basics: file paths
    • 🐧Linux basics: SWAP file
  • 🚫Bytes of Caution
Powered by GitBook
On this page
  1. How-To Guides

Integrating Git on your local host

2025-02-08

Integrating your local host machine and code editor with Git enables a seamless workflow for version control and collaboration. In this guide, we'll walk you through the steps to set up SSH keys, clone a GitLab repository, and push changes from your local environment.

Step 1: Generate SSH Key Pair

Run the following command to generate an SSH key pair. The -t ed25519 option specifies the key type, and the -C option adds a comment (usually your email address).

ssh-keygen -t ed25519 -C "your-email-address"

This will prompt you to choose a location to save the key (default is ~/.ssh/id_ed25519), and optionally, set a passphrase for extra security.

Start the SSH agent:

After generating the key pair, run the following command to start the SSH agent, which will manage your SSH keys:

eval "$(ssh-agent -s)"

Add your SSH key to the agent:

Next, add the private key (id_ed25519) to the SSH agent. Make sure the path points to where your SSH keys are stored.

    ssh-add ~/user/.ssh/id_ed25519

Replace the path if necessary.

Step 2: Add the SSH Key to GitLab

Copy the SSH public key:

Use cat to display your SSH public key, and copy the output:

    cat ~/.ssh/id_ed25519.pub

Add your SSH key to GitLab: Go to your GitLab SSH keys page. Paste the copied public key into the "Key" field and give it a descriptive title. Click "Add key."

***Step 3: Test SSH Connection***

To confirm that your SSH key is working, run the following command:

ssh -T git@gitlab.com

If successful, GitLab will greet you with a message confirming that the authentication was successful.

Step 4: Clone Your GitLab Repository

Now that your SSH key is set up, you can clone your GitLab repository to your local host:

git clone git@gitlab.com:gitlab-username/repository.git

This command clones the specified repository to your local machine, enabling you to work with it.

Step 5: Update and Push Changes to the Repository

Make changes to a file:

Edit a file in your cloned repository as needed. Once you're ready to push changes, follow these steps. Stage changes for commit: Use git add . to stage all modified files:

git add .

You can also specify specific files instead of using the dot (.) to stage all files.

Check the status:

Run git status to see which files have been staged for commit:

git status

Commit your changes:

Commit your changes with a descriptive message:

git commit -m "first commit message"

If this is your first time committing, you may need to set your Git username and email globally:

git config --global user.email "your-email-address"
git config --global user.name "gitlab-username"

Push your changes:

Finally, push your committed changes to GitLab:

    git push origin main

This uploads your changes to the main branch of your GitLab repository.

Conclusion

By following these steps, you can successfully integrate your local server and code editor with GitLab, streamlining your development process. This setup ensures that your code remains versioned and safely stored on GitLab, and you can easily collaborate with others.

PreviousHow-To GuidesNextLoad Balancing with HAProxy

Last updated 4 months ago

πŸ“š
Page cover image