If you want to set up your new pet or study project from scratch in 2025, you might want to use https://github.com for version control and Docker for running a dev environment to get a smooth and quick start. Let’s start with a git repository. Here is a step by step instruction.
- Go get a gihub.com account
- Start a new repository there. Let’s assume you called it
api
- Providing you have git installed already on your computer and having some folder structure and code for your project you first run
git init
in the root folder of your project. - You can add files to stage by
git add .
, commit them withgit commit -m "description"
however your repository will stay local yet. - We need to set up an ssh access to your repository. Let’s create an ssh key first:
ssh-keygen -t ed25519 -C "mail@gmail.com"
then pick any name for the key. There will be two: a private one and a public one (with the extension .pub). By default the keys will be stored in the subfolder .ssh of your home folder. Let’s assume you named your key my_key - Copy the contents of the newly added pub key to the clipboard. On MacOS you can do it with
pbcopy < ~/.ssh/my_key.pub
- Go to the settings of your ssh access on github repository settings page and copy paste the pub key there.
- Add the newly added key to your system
ssh-add -K ~/.ssh/my_key
- Find and edit your ssh config, usually it’s located in ~/.ssh/config
- Add your new key there:
Host github.GITHUB_REPOSITORY_NAME HostName github.com AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/my_key
11. Done with ssh, let’s set up the repository itself. Let’s assume your main branch is called main rather than master (considered more politically correct now). Add origin git remote add origin git@github.GITHUB_REPOSITORY_NAME:GITHUB_REPOSITORY_USERNAME/api.git
here api.git is the name of your git repository
12. Set URL: git remote set-url origin git@github.
Pay attention to GITHUB_REPOSITORY_NAME:GITHUB_REPOSITORY_USERNAME
/api.git
– this is important to set it up if you want to work with more than one Git repositories on the same computer, and you want them to use separate keys to access each of them.GITHUB_REPOSITORY_NAME
13. Check your links to the remote repository: git remote -v
14. Try to push your code to this remote repository: git push -u origin main
Enjoy your work!