git from the command line:
sudo apt-get install git
Currently for me, this is only installing git version 2.25.1.
jake@ubuntu:~$ git --version git version 2.25.1
To be able to set a defaultBranch name, version 2.28 is required. To upgrade git to the latest version:
sudo add-apt-repository ppa:git-core/ppa sudo apt update sudo apt install git
How to Configure
git settings only need be set once and can be added to or updated later.
Setting the user’s name and email address for
# configure globally so don't have to set with each project git config --global user.name "Jake" git config --global user.email "email@example.com"
git commit uses this information and is baked into the commits.
Setting the Editor for
git config --global core.editor "nano"
This is the text editor
git will use when it requires you to type in a message. If none are set, it will use your system’s default editor.
Setting the color.ui:
git config --global color.ui "true"
The default for this is auto and can be more specific as to what you want to colour:
color.branch color.diff color.interactive color.status
Setting push.default to simple:
Simple allows different branch names and does not force you to push ALL branches at the same time.
git config --global push.default "simple"
Setting defaultBranch to
With git version 2.28+, you can set a name for the default branch that is created:
git config --global init.defaultBranch main
How to view the
git configuration settings:
git config --list
Produced the following output from my configuration:
user.name=Jake firstname.lastname@example.org core.editor=nano color.ui=true push.default=simple init.defaultbranch=main
ED25519 SSH Keys:
By generating an ED25519 SSH Key and adding it to your GitLab profile, it allows you to push and pull to your repositories without having to enter your username and password every time.
Type out the following command replacing <comment> with a comment (I just use the computer name):
Generate ED25519 SSH key:
ssh-keygen -t ed25519 -C "<comment>"
Hit enter for any of the questions it asks you
Add SSH key to GitLab account
Open up the file, copy all of it’s contents, and paste the contents into your GitLab account as the Key. From GitLab->User Settings->Preferenes->SSH Keys
You also need to give it a title (again, I use the computer name – with VMWare: if it’s from a VM) and an expiration date.
Now that authentication is setup using an SSH Key, you can test to ensure it worked correctly by typing:
ssh -T email@example.com
yes when asked, this will set up
jake@ubuntu:~/git-test$ ssh -T firstname.lastname@example.org The authenticity of host 'gitlab.com (172.65.251.x)' can't be established. ECDSA key fingerprint is SHA256:HbW3g8zUj_____q1x8xdGUrliXFzSnUw. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'gitlab.com,172.65.251.x' (ECDSA) to the list of known hosts. Welcome to GitLab, @jake!
I was now able to grab one of my repos without having to provide credentials with:
git clone email@example.com:sipofwater/scripts.git