Skip to content

Git

Git is a neat tool we use to track source code, ensuring the version we’re working with is always the latest. As a developer, Git will most likely be the tool you use to send in the changes you’ve made to the source code so everyone else can incorporate them.

Go to this website and install the version of Git for your operating system. If you’re on Windows, it will likely be this one:

Git download options on git-scm.com

Once it has been downloaded, launch the installer and follow the prompts. Just click Next through all the configuration windows. It should already have the default configurations selected.

Open the command line by pressing your Windows key and searching for cmd, then run the application called Command Prompt.

Which application to launch

It should open an old Windows-style command line application. Type this command into the console (it is case sensitive):

Get git version
git --version

It should print out the current version of Git you have downloaded.

Get Version Command Example

Git tracks code by creating hashes (a really big random number) along with the metadata of the person doing the check-in. Counterintuitively, this is tracked with a file locally, and it’s usually hidden in the same folder as your source code.

Because it requires that metadata to perform its operations, we need to set it up, or Git will not work.

Your signature is just your name. It doesn’t have to be your real name, in fact many people treat it like a username and just put their most common online alias in. However, it is the name that will appear in Git files alongside your check-ins, and it’s a name others could potentially see if they’re looking around the source control, so please make sure your name is appropriate.

Set your Git username:

Set Git Name
git config --global user.name "<YOUR_NAME>"

Example:

Set Git Name Example 1
git config --global user.name "Anita Man"

or

Set Git Name Example 2
git config --global user.name "Kash Money Balenciaga"

Go crazy, the world is your oyster here. This is a name that realistically will only ever get read by a computer program 99% of the time.

Setting Your Name

Git also requires you to add your email. This is for two reasons: it helps tie changes to the domain they’re coming from, so if you ever lose your system, it can validate you are the same person by your email. Also, Git is nearly completely isolated to the files you download from the repository, meaning there is nothing stopping you from taking the source code and opening a repository somewhere else with nearly all the history preserved.

Set your Git email:

Set Git Email
git config --global user.email "<YOUR_EMAIL>"

Example:

Set Git Email Example
git config --global user.email "Josh-Macintire@gmail.com"

Setting Your Email

This is technically optional, since most modern Git versions already default to main rather than the older convention of calling the primary branch master or origin. It’s still good hygiene to make sure your default branch is set to main.

Set init.defaultBranch to main
git config --global init.defaultBranch main

Initialize to main branch

4. Set Up Your SSH Key for Codeberg (or Any SCM)

Section titled “4. Set Up Your SSH Key for Codeberg (or Any SCM)”

In order to pull and push code, you need to give whatever service you’re using to host your source code a way to verify that you are who you say you are, and that you’re authorized to perform the actions you’re trying to do. We can do that with an SSH key: a personal encryption string that you use solely for that service, creating a secure personal communication tunnel.

SSH Gen Command
ssh-keygen -t ed25519 -C "YOUR_EMAIL"

Example:

SSH Gen Command Example
ssh-keygen -t ed25519 -C "Bear@Polar.com"

Generate your SSH Key

With our SSH key pair fresh out of the oven and steaming, this is a premium time to copy our public key. In encryption, a public key is basically the key that you give to everyone so they can encrypt their data, such that only you, the person with the private key, can unlock it.

if you are on general command line, just open the pub using the type command on the file in the command line to have it dump the raw text of the SSH key into the terminal, highight the text and copy it to your clip board

command Line
type C:\Users\<YOUR_USER>\.ssh\id_ed25519.pub

if you’re comfy with powershell;

powershell
Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub

here is the bash command if Linux/IOS if you can run bash commands on powershell you can run this command

Get Gen Key
cat ~/.ssh/id_ed25519.pub

any of these options work, if you followed the CMD example using command line it should spit something out that looks like this:

resulting ssh key

Lastly: Paste the Public Key into Your Codeberg Auth Settings

Section titled “Lastly: Paste the Public Key into Your Codeberg Auth Settings”
  1. Go to CodeBerg and sign in

code berg login

  1. Next, go to your user settings located under your profile in the top right of the window.

user settings location

  1. Find the ‘SSH/GPG’ option in the nav bar and open to that window.

user settings ssh location

  1. Click the ‘Add Key’ button in the SSH menu within the ‘SSH/GPG’ options console.

add key location

  1. Name the key and paste the SSH key your console gave you into the key window and submit it.

Creating the key

  1. Test it out, try using Git with any of the STARS repositories on code berg.
    • Note, the first time you try to use it, it may bark and say that you are not authenticated, immediately try again. Often times your inital request takes too long to authenticate and returns a 403 error before you get your access token. After you have the token, you should be able to do whatever you want for approximately an hour before the token goes stale and you will need to log in again. Its just as simple as trying to do something in Git and having it tell you that you aren’t authorized.

Authentication Failing, but not really