62 lines
1.7 KiB
Markdown
62 lines
1.7 KiB
Markdown
---
|
||
title: Setting Up Git
|
||
description: Steps to get up and running with Git
|
||
published: true
|
||
date: 2024-07-04T22:20:23.659Z
|
||
tags:
|
||
editor: markdown
|
||
dateCreated: 2024-06-30T20:44:58.238Z
|
||
---
|
||
|
||
# Description:
|
||
|
||
Basic steps to get git connected to server and able to clone repos.
|
||
|
||
# Steps:
|
||
|
||
1. Install and configure git:
|
||
|
||
```
|
||
git config --global user.name "Your Name"
|
||
git config --global user.email "yourname@example.com"
|
||
git config --global init.defaultBranch main
|
||
git config --global color.ui auto
|
||
git config --global pull.rebase false
|
||
git config --global core.editor "code --wait"
|
||
|
||
|
||
```
|
||
2. Create SSH Key
|
||
```
|
||
ssh-keygen -t ed25519
|
||
```
|
||
3. Copy public key to server
|
||
```
|
||
cat ~/.ssh/id_ed25519.pub
|
||
```
|
||
4. Clone desired repo using ssh
|
||
|
||
---
|
||
|
||
# Notes:
|
||
In the even you rename the key to something other than `id_rsa`, add config file to .ssh folder
|
||
`touch ~/.ssh/config` then add:
|
||
|
||
```bash
|
||
Host github.com or git server
|
||
Hostname github.com
|
||
IdentityFile /path/to/privateKey
|
||
```
|
||
`stat -c %a keyfile` checks permissions of key if needed, must be 600
|
||
`chmod 600 keyfile`
|
||
|
||
Taken from [this superuser thread](https://superuser.com/questions/232373/how-to-tell-git-which-private-key-to-use):
|
||
|
||
> Regarding contacting the same host with different keys: Here it is essential to understand that in `.ssh/config`
|
||
> `Host` is a *custom name* you can give to the host specified under `HostName`.
|
||
> The github.com part in the git URL git@github.com:torvalds/linux.git refers to this Host and thus has to match it exactly.
|
||
>If you have a second Github ssh key, you can create a section Host github2 in .ssh/config and then use the URL git@github2:torvalds/linux.g(see also superuser.com/a/1519694/96128).
|
||
–user905686
|
||
Commented Apr 12, 2021 at 17:42
|
||
|