Gitea – Setup SSH and Repository

In this tutorial, you’ll be learning how to setup SSH and a repository on Gitea

What is Gitea ?

  • It is a self-hosted Git Service similar to Github, Bitbucket, etc..
  • It serves as your very own private repository management system
  • It is lightweight, open source and free to use
  • It can be deployed and managed easily with Docker and Docker-Compose

Read more here: https://gitea.io/en-us/

For more blogs, visit: Blogs
For Docker related Blogs, visit: Docker

Pre-requisites

Steps to SSH key on Gitea

1. Browse to your installation as setup in the previous tutorial and login with your credentials (Refer to the previous tutorial here: Gitea – A Self-Hosted Private Git Server on Docker)

Gitea
Gitea

2. You should now be able to see your Gitea Dashboard. Now navigate to the settings as shown below and move to the “SSH/GPG Keys” section

Gitea
Gitea

3. Click on the Add Key button and paste the public key of your PC and finally click on the Add Key button

# Get the public key by this command
cat ~/.ssh/id_rsa.pub
# Copy the Key
# If public key is not generated generate by using this command
ssh-keygen
Gitea
Gitea

Congratulations!! Your SSH key is now added to Gita

Steps to Create a Repo on Gitea

1. Click on the create repo button as shown below

Gitea

2. Add in the requirements for your repo as shown below. (Enable the Initialize Repo option to automatically add the .gitidnore and ReadME file)

Gitea
Gitea

3. Create the repository and now you should be able to see it on your gitea installation. Copy the SSH link to the repo as shown below

Gitea

4. Let us now clone this repo and try to add and push a file to the repo

# Clone your repo using the SSH link
git clone <SSH-Repo-Link>
# View the repo
ls
# Navigate to the repo
cd <Repo-Name>
# Refer to the image below
Gitea

5. Let’s now create a file to called testfile and push it to the repo

# Create a file called testfile
touch testfile
# Add the file to git
git add testfile
# Commit the file along with a commit message
git commit -m "Added Testfile"
# Push the changes to the repo
git push
Gitea

6. Now check the repo on Gitea. You should be able to see the file that we have pushed

Gitea

Congratulations!! You have successfully created a repo on Gitea and pushed a file to it

Steps to push existing repository to Gitea

1. Click on the create new repository button as shown below

Gitea

2. Add in the details as per your requirement (Here, we will not be enabling the initialize repository option since we already have an existing local repository

Gitea
Gitea

3. You should now be able to see the repo on gitea as shown below

Gitea

4. Let us now create a sample repo with a testfile on our local environment

# Create a directory
mkdir <Repo-Name>
# Navigate into the directory
cd <Repo-Name>
# Create a test file
touch testfile
# Check if the file has been created 
ls
# Refer image below
Gitea

5. Let us now push this repo to Gitea

# Initialize the repository
git init
# Add the test file
git add testfile
# Commit the changes with commit message
git commit -m "Added testfile"
# Add the remote of the repo (Copy the command from the Gitea repo home page)
git remote add origin <SSH-Repo-Link>
# Push to the repo
git push -u origin master
Gitea

6. Verify the repo on Gitea

Gitea

Congratulations!! You’ve successfully configured SSH keys and learnt to create a repo on Gitea

5412cookie-checkGitea – Setup SSH and Repository

3 Comments

  1. Avatar gralion torile

    You have brought up a very superb details , thankyou for the post.

  2. Thank you for any other great article. Where else could anyone get that type of information in such an ideal means of writing? I’ve a presentation subsequent week, and I’m on the look for such info.

  3. Im grateful for the post.Really thank you! Fantastic.

Leave a Comment

Your email address will not be published. Required fields are marked *