> For the complete documentation index, see [llms.txt](https://security.navidnaf.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://security.navidnaf.com/spells/git.md).

# git

This page will have all the things related to git.

{% embed url="<https://git-scm.com/>" %}

{% code overflow="wrap" %}

```bash
git --version

# Configure Git
git config --global user.name "Name"
git config --global user.email "abc@xyz.com"

# if we want to use separate name and mail; initiate a git and then setup new username and mail using the following
git config user.name "Name"
git config user.email "abc@xyz.com"
```

{% endcode %}

## Git Repository Setup

{% code overflow="wrap" %}

```bash
# Initialize Git in a directory
git init

# Checking current status of git. Displays the state of the working directory and the staging area
git status

# Adding to the staging area
git add <FILE>
git add . (or) git add --all
```

{% endcode %}

## Git Commit

{% code overflow="wrap" %}

```bash
# Final Commit from the staging area
git commit -m "Added First Files"
```

{% endcode %}

## Connecting to Github

```bash
# Github 
Login > New Repository > Create Repository

# push an existing repository from the command line
git remote add origin <.....>
git branch -M main
git push -u origin main
```

## Github SSH Key Setup

<pre class="language-bash"><code class="lang-bash">ls -al ~/.ssh
ssh-keygen -t rsa -b 4096 -C "navidfazlerabbi@iut-dhaka.edu"
<strong>eval "$(ssh-agent -s)" # run ssh agent in the background
</strong>ssh-add ~/.ssh/id_rsa # adding id_rsa to the ssh-agent
pbcopy &#x3C; ~/.ssh/id_rsa.pub

# In Github
Settings > SSH and GPG Keys > New SSH Key
</code></pre>
