Step 1: Install Git
sudo apt update
sudo apt upgrade
2.Install Git
sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git
3.Verify version
git --version
Step 2: Configure Git and GitHub I went to GitHub.com and created an account! During the account setup, it asked me for an email address. This needs to be a real email and will be used by default to identify your contributions. If you are privacy conscious or just don’t want our email address to be publicly available, make sure we tick the following two boxes on the Email Settings page after you have signed in:
X Keep my email adresses private
X Block command line pushes that expose my email
With the private email:
git config --global user.name "Your Name"
git config --global user.email "yourname@example.com"
If we opted to use the private GitHub email address, the second command will look something like this:
git config --global user.email "123456789+odin@users.noreply.github.com" # Remember to use your own private GitHub email here.
GitHub recently changed the default branch on new repositories from master to main. Change the default branch for Git using this command:
git config --global init.defaultBranch main
To enable colorful output with git, type
git config --global color.ui auto
We’ll also likely want to set your default branch reconciliation behavior to merging.
git config --global pull.rebase false
To verify that things are working properly, enter these commands and verify whether the output matches your name and email address.
git config --get user.name
git config --get user.email
Create an SSH key:
We check if we have an SSH key.
ls ~/.ssh/id_ed25519.pub
If we do not have an Ed25519 algorithm SSH key, we create one in the terminal with this command.
ssh-keygen -t ed25519
Now you need to copy your public SSH key. To do this, we’re going to use a command called cat to read the file to the console.
cat ~/.ssh/id_ed25519.pub
Highlight and copy the entire output from the command. If you followed the instructions above, the output will likely begin with ssh-ed25519 and end with your username@hostname. Now, go back to GitHub in your browser window and paste the key you copied into the key field. Keep the key type as Authentication Key and then, click Add SSH key. You’re done! You’ve successfully added your SSH key!
Testing your SSH connection After you've set up your SSH key and added it to GitHub, you can test your connection Open Terminal.
Enter the following:
ssh -T git@github.com
# Attempts to ssh to GitHub
If Egee SSH is correct, press the letter y and then type "yes" and press enter.